Exemplo n.º 1
0
        private void CollectCodeCoverage(RunnerInfo runnerInfo, TestParameters testParameters)
        {
            AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo);

            var arguments = this.CreateArguments(runnerInfo, testParameters, out var trxFilePath);

            this.InvokeVsTest(arguments);

            this.ValidateSummaryStatus(
                testParameters.ExpectedPassedTests,
                testParameters.ExpectedSkippedTests,
                testParameters.ExpectedFailedTests);

            var actualCoverageFile = CodeCoverageTests.GetCoverageFileNameFromTrx(trxFilePath, resultsDirectory);

            Console.WriteLine($@"Coverage file: {actualCoverageFile}  Results directory: {resultsDirectory} trxfile: {trxFilePath}");
            Assert.IsTrue(File.Exists(actualCoverageFile), "Coverage file not found: {0}", actualCoverageFile);

            var coverageDocument = this.GetXmlCoverage(actualCoverageFile);

            if (testParameters.CheckSkipped)
            {
                this.AssertSkippedMethod(coverageDocument);
            }

            this.ValidateCoverageData(coverageDocument, testParameters.AssemblyName);

            Directory.Delete(this.resultsDirectory, true);
        }
Exemplo n.º 2
0
        private void CollectCodeCoverage(RunnerInfo runnerInfo, string targetPlatform, bool withRunsettings)
        {
            AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo);

            var trxFileName        = Guid.NewGuid().ToString();
            var trxFileNamePattern = trxFileName + "*.trx";
            var arguments          = CreateArguments(runnerInfo, targetPlatform, withRunsettings, trxFileName);

            // Delete existing trx files
            var dir = new DirectoryInfo(this.resultsDirectory);

            if (dir.Exists)
            {
                foreach (var file in dir.EnumerateFiles(trxFileNamePattern))
                {
                    file.Delete();
                }
            }

            // Invoke tests
            this.InvokeVsTest(arguments);

            // Validate
            this.ValidateSummaryStatus(1, 1, 1);
            var actualCoverageFile = CodeCoverageTests.GetCoverageFileNameFromTrx(trxFileNamePattern, this.resultsDirectory);

            Console.WriteLine($@"Coverage file: {actualCoverageFile}  Results directory: {resultsDirectory} trxfile pattern: {trxFileNamePattern}");
            Assert.IsTrue(File.Exists(actualCoverageFile), "Coverage file not found: {0}", actualCoverageFile);

            // Microsoft.VisualStudio.Coverage.Analysis assembly not avaialble for .NET Core.
#if NET451
            this.ValidateCoverageData(actualCoverageFile);
#endif
            Directory.Delete(this.resultsDirectory, true);
        }
Exemplo n.º 3
0
        public void RunMultipleTestAssembliesWithCodeCoverage(RunnerInfo runnerInfo)
        {
            AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo);

            var assemblyPaths = this.BuildMultipleAssemblyPath("SimpleTestProject.dll", "SimpleTestProject2.dll").Trim('\"');

            var arguments = CreateCodeCoverageArguments(runnerInfo, assemblyPaths, out var trxFilePath);

            this.InvokeVsTest(arguments);

            this.ExitCodeEquals(1); // failing tests

            var actualCoverageFile = CodeCoverageTests.GetCoverageFileNameFromTrx(trxFilePath, resultsDirectory);

            Console.WriteLine($@"Coverage file: {actualCoverageFile}  Results directory: {resultsDirectory} trxfile: {trxFilePath}");
            Assert.IsTrue(File.Exists(actualCoverageFile), "Coverage file not found: {0}", actualCoverageFile);
        }
Exemplo n.º 4
0
        private void CollectCodeCoverage(RunnerInfo runnerInfo, string targetPlatform, bool withRunsettings)
        {
            AcceptanceTestBase.SetTestEnvironment(this.testEnvironment, runnerInfo);

            var arguments = CreateArguments(runnerInfo, targetPlatform, withRunsettings, out var trxFilePath);

            this.InvokeVsTest(arguments);

            this.ValidateSummaryStatus(1, 1, 1);

            var actualCoverageFile = CodeCoverageTests.GetCoverageFileNameFromTrx(trxFilePath, resultsDirectory);

            Console.WriteLine($@"Coverage file: {actualCoverageFile}  Results directory: {resultsDirectory} trxfile: {trxFilePath}");
            Assert.IsTrue(File.Exists(actualCoverageFile), "Coverage file not found: {0}", actualCoverageFile);

            // Microsoft.VisualStudio.Coverage.Analysis assembly not avaialble for .NET Core.
#if NET451
            this.ValidateCoverageData(actualCoverageFile);
#endif
            Directory.Delete(this.resultsDirectory, true);
        }