void ExecutesTest(bool excludeNetFramework) { Logger.Info(excludeNetFramework ? "Exclude net framework" : "Include net framework"); var testConfigurations = from project in TestProjects from framework in project.GetTargetFrameworks(excludeNetFramework) select new { project, framework }; DotNetTest(_ => { return(_ .SetConfiguration(Configuration) .SetNoRestore(InvokedTargets.Contains(Restore)) .SetNoBuild(InvokedTargets.Contains(Compile)) .ResetVerbosity() .SetResultsDirectory(TestResultDirectory) .CombineWith(testConfigurations, (_, v) => _ .SetProjectFile(v.project) .SetFramework(v.framework) .SetLogger($"trx;LogFileName={v.project.Name}.trx"))); }); TestResultDirectory.GlobFiles("*.trx").ForEach(x => AzurePipelines?.PublishTestResults( type: AzurePipelinesTestResultsType.VSTest, title: $"{Path.GetFileNameWithoutExtension(x)} ({AzurePipelines.StageDisplayName})", files: new string[] { x })); }
void ReportTestResults() { TestResultDirectory.GlobFiles("*.trx").ForEach(x => AzurePipelines.Instance?.PublishTestResults( type: AzurePipelinesTestResultsType.VSTest, title: $"{Path.GetFileNameWithoutExtension(x)} ({AzurePipelines.Instance.StageDisplayName})", files: new string[] { x })); }
void ReportTestCount() { IEnumerable <string> GetOutcomes(AbsolutePath file) => XmlTasks.XmlPeek( file, "/xn:TestRun/xn:Results/xn:UnitTestResult/@outcome", ("xn", "http://microsoft.com/schemas/VisualStudio/TeamTest/2010")); var resultFiles = TestResultDirectory.GlobFiles("*.trx"); var outcomes = resultFiles.SelectMany(GetOutcomes).ToList(); var passedTests = outcomes.Count(x => x == "Passed"); var failedTests = outcomes.Count(x => x == "Failed"); var skippedTests = outcomes.Count(x => x == "NotExecuted"); ReportSummary(_ => _ .When(failedTests > 0, _ => _ .AddPair("Failed", failedTests.ToString())) .AddPair("Passed", passedTests.ToString()) .When(skippedTests > 0, _ => _ .AddPair("Skipped", skippedTests.ToString()))); }