コード例 #1
0
        public void DeployShouldReturnFalseWhenNoDeploymentItemsOnTestCase()
        {
            var testCase = new TestCase("A.C.M", new System.Uri("executor://testExecutor"), "A");

            testCase.SetPropertyValue(DeploymentItemUtilityTests.DeploymentItemsProperty, null);
            var testRunDirectories = new TestRunDirectories(RootDeploymentDirectory);

            this.mockFileUtility.Setup(fu => fu.DoesDirectoryExist(It.Is <string>(s => !(s.EndsWith(".dll") || s.EndsWith(".config"))))).Returns(true);
            this.mockFileUtility.Setup(fu => fu.DoesFileExist(It.IsAny <string>())).Returns(true);
            this.mockAssemblyUtility.Setup(
                au => au.GetFullPathToDependentAssemblies(It.IsAny <string>(), It.IsAny <string>(), out this.warnings))
            .Returns(new string[] { });
            this.mockAssemblyUtility.Setup(
                au => au.GetSatelliteAssemblies(It.IsAny <string>()))
            .Returns(new List <string> {
            });

            Assert.IsFalse(
                this.deploymentUtility.Deploy(
                    new List <TestCase> {
                testCase
            },
                    testCase.Source,
                    this.mockRunContext.Object,
                    this.mocktestExecutionRecorder.Object,
                    testRunDirectories));
        }
コード例 #2
0
        private TestDeployment CreateAndSetupDeploymentRelatedUtilities(out TestRunDirectories testRunDirectories)
        {
            var currentExecutingFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            testRunDirectories = new TestRunDirectories(currentExecutingFolder);

            this.mockFileUtility.Setup(fu => fu.DoesDirectoryExist(It.Is <string>(s => !s.EndsWith(".dll")))).Returns(true);
            this.mockFileUtility.Setup(fu => fu.DoesFileExist(It.IsAny <string>())).Returns(true);
            var mockAssemblyUtility = new Mock <AssemblyUtility>();

            mockAssemblyUtility.Setup(
                au => au.GetFullPathToDependentAssemblies(It.IsAny <string>(), It.IsAny <string>(), out this.warnings))
            .Returns(new string[] { });
            mockAssemblyUtility.Setup(
                au => au.GetSatelliteAssemblies(It.IsAny <string>()))
            .Returns(new List <string> {
            });
            this.mockFileUtility.Setup(fu => fu.GetNextIterationDirectoryName(It.IsAny <string>(), It.IsAny <string>()))
            .Returns(testRunDirectories.RootDeploymentDirectory);

            var deploymentItemUtility = new DeploymentItemUtility(this.mockReflectionUtility.Object);

            return(new TestDeployment(
                       deploymentItemUtility,
                       new DeploymentUtility(deploymentItemUtility, mockAssemblyUtility.Object, this.mockFileUtility.Object),
                       this.mockFileUtility.Object));
        }
コード例 #3
0
ファイル: TestResult.cs プロジェクト: sshyran/vstest
        /// <summary>
        /// Initializes a new instance of the <see cref="TestResult"/> class.
        /// </summary>
        /// <param name="computerName">
        /// The computer name.
        /// </param>
        /// <param name="runId">
        /// The run id.
        /// </param>
        /// <param name="test">
        /// The test.
        /// </param>
        /// <param name="outcome">
        /// The outcome.
        /// </param>
        public TestResult(
            Guid runId,
            Guid testId,
            Guid executionId,
            Guid parentExecutionId,
            string resultName,
            string computerName,
            TestOutcome outcome,
            TestType testType,
            TestListCategoryId testCategoryId,
            TrxFileHelper trxFileHelper)
        {
            Debug.Assert(computerName != null, "computername is null");
            Debug.Assert(!Guid.Empty.Equals(executionId), "ExecutionId is empty");
            Debug.Assert(!Guid.Empty.Equals(testId), "TestId is empty");

            this.Initialize();

            this.id           = new TestResultId(runId, executionId, parentExecutionId, testId);
            this.resultName   = resultName;
            this.testType     = testType;
            this.computerInfo = computerName;
            this.outcome      = outcome;
            this.categoryId   = testCategoryId;
            this.relativeTestResultsDirectory = TestRunDirectories.GetRelativeTestResultsDirectory(executionId);
            this.trxFileHelper = trxFileHelper;
        }
コード例 #4
0
ファイル: ns13TestDeployment.cs プロジェクト: kant2002/testfx
        /// <summary>
        /// Deploy files related to the list of tests specified.
        /// </summary>
        /// <param name="tests"> The tests. </param>
        /// <param name="runContext"> The run context. </param>
        /// <param name="frameworkHandle"> The framework handle. </param>
        /// <returns> Return true if deployment is done. </returns>
        public bool Deploy(IEnumerable <TestCase> tests, IRunContext runContext, IFrameworkHandle frameworkHandle)
        {
            Debug.Assert(tests != null, "tests");

            // Reset runDirectories before doing deployment, so that older values of runDirectories is not picked
            // even if test host is kept alive.
            RunDirectories = null;

            this.adapterSettings = MSTestSettingsProvider.Settings;
            bool canDeploy          = this.CanDeploy();
            var  hasDeploymentItems = tests.Any(test => this.deploymentItemUtility.HasDeploymentItems(test));

            // deployment directories should not be created in this case,simply return
            if (!canDeploy && hasDeploymentItems)
            {
                return(false);
            }

            RunDirectories = this.deploymentUtility.CreateDeploymentDirectories(runContext);

            // Deployment directories are created but deployment will not happen.
            // This is added just to keep consistency with MSTestv1 behavior.
            if (!hasDeploymentItems)
            {
                return(false);
            }

            // Object model currently does not have support for SuspendCodeCoverage. We can remove this once support is added
#if !NETSTANDARD1_5 && !NET5_0
            using (new SuspendCodeCoverage())
#endif
            {
                // Group the tests by source
                var testsBySource = from test in tests
                                    group test by test.Source into testGroup
                                    select new { Source = testGroup.Key, Tests = testGroup };

                var runDirectories = RunDirectories;
                foreach (var group in testsBySource)
                {
                    // do the deployment
                    this.deploymentUtility.Deploy(@group.Tests, @group.Source, runContext, frameworkHandle, RunDirectories);
                }

                // Update the runDirectories
                RunDirectories = runDirectories;
            }

            return(true);
        }
コード例 #5
0
        /// <summary>
        /// Create deployment directories
        /// </summary>
        /// <param name="runContext">The run context.</param>
        /// <returns>TestRunDirectories instance.</returns>
        public TestRunDirectories CreateDeploymentDirectories(IRunContext runContext)
        {
            var resultsDirectory        = this.GetTestResultsDirectory(runContext);
            var rootDeploymentDirectory = this.GetRootDeploymentDirectory(resultsDirectory);

            var result             = new TestRunDirectories(rootDeploymentDirectory);
            var inDirectory        = result.InDirectory;
            var outDirectory       = result.OutDirectory;
            var inMachineDirectory = result.InMachineNameDirectory;

            this.FileUtility.CreateDirectoryIfNotExists(rootDeploymentDirectory);
            this.FileUtility.CreateDirectoryIfNotExists(inDirectory);
            this.FileUtility.CreateDirectoryIfNotExists(outDirectory);
            this.FileUtility.CreateDirectoryIfNotExists(inMachineDirectory);

            return(result);
        }
コード例 #6
0
        private TestCase GetTestCaseAndTestRunDirectories(string deploymentItemPath, string defaultDeploymentItemOutputDirectoryout, out TestRunDirectories testRunDirectories)
        {
            var testCase = new TestCase("A.C.M", new System.Uri("executor://testExecutor"), Assembly.GetExecutingAssembly().Location);
            var kvpArray = new[]
            {
                new KeyValuePair <string, string>(
                    deploymentItemPath,
                    defaultDeploymentItemOutputDirectoryout)
            };

            testCase.SetPropertyValue(DeploymentItemUtilityTests.DeploymentItemsProperty, kvpArray);
            var currentExecutingFolder = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);

            testRunDirectories = new TestRunDirectories(currentExecutingFolder);

            return(testCase);
        }
コード例 #7
0
ファイル: UnitTestResult.cs プロジェクト: navin22/nvstest
        /// <summary>
        /// Initializes a new instance of the <see cref="TestResult"/> class.
        /// </summary>
        /// <param name="computerName">
        /// The computer name.
        /// </param>
        /// <param name="runId">
        /// The run id.
        /// </param>
        /// <param name="test">
        /// The test.
        /// </param>
        /// <param name="outcome">
        /// The outcome.
        /// </param>
        public UnitTestResult(string computerName, Guid runId, UnitTestElement test, TestOutcome outcome)
        {
            Debug.Assert(computerName != null, "computername is null");
            Debug.Assert(test != null, "test is null");
            Debug.Assert(!Guid.Empty.Equals(test.ExecutionId.Id), "ExecutionId is empty");
            Debug.Assert(!Guid.Empty.Equals(test.Id.Id), "Id is empty");

            this.Initialize();

            this.id           = new TestResultId(runId, test.ExecutionId, test.Id);
            this.testName     = test.Name;
            this.testType     = test.TestType;
            this.computerInfo = computerName;

            this.outcome    = outcome;
            this.categoryId = test.CategoryId;
            this.relativeTestResultsDirectory = TestRunDirectories.GetRelativeTestResultsDirectory(test.ExecutionId.Id);
        }
コード例 #8
0
 /// <summary>
 /// Reset the static varaible to default values. Used only for testing purposes.
 /// </summary>
 internal static void Reset()
 {
     RunDirectories = null;
 }
コード例 #9
0
        public bool Deploy(IEnumerable <TestCase> tests, string source, IRunContext runContext, ITestExecutionRecorder testExecutionRecorder, TestRunDirectories runDirectories)
        {
            IList <DeploymentItem> deploymentItems = this.DeploymentItemUtility.GetDeploymentItems(tests);

            // we just deploy source if there are no deployment items for current source but there are deployment items for other sources
            return(this.Deploy(source, runContext, testExecutionRecorder, deploymentItems, runDirectories));
        }
コード例 #10
0
        private bool Deploy(string source, IRunContext runContext, ITestExecutionRecorder testExecutionRecorder, IList <DeploymentItem> deploymentItems, TestRunDirectories runDirectories)
        {
            ValidateArg.NotNull(runDirectories, "runDirectories");
            if (EqtTrace.IsInfoEnabled)
            {
                EqtTrace.Info("MSTestExecutor: Found that deployment items for source {0} are: ", source);
                foreach (var item in deploymentItems)
                {
                    EqtTrace.Info("MSTestExecutor: SourcePath: - {0}", item.SourcePath);
                }
            }

            // Do the deployment.
            EqtTrace.InfoIf(EqtTrace.IsInfoEnabled, "MSTestExecutor: Using deployment directory {0} for source {1}.", runDirectories.OutDirectory, source);
            var warnings = this.Deploy(new List <DeploymentItem>(deploymentItems), source, runDirectories.OutDirectory, this.GetTestResultsDirectory(runContext));

            // Log warnings
            LogWarnings(testExecutionRecorder, warnings);
            return(deploymentItems != null && deploymentItems.Count > 0);
        }