private static RunStepResult DiscoverUnitTests(IRunExecutorHost host, RunStartParams rsp, RunStepInfo rsi) { if (!host.CanContinue()) { throw new OperationCanceledException(); } var output = RunTestHost("discover", rsp); RunStepStatus rss = RunStepStatus.Succeeded; if (output.Item1 != 0) { rss = RunStepStatus.Failed; } var testsPerAssembly = PerDocumentLocationDTestCases.Deserialize(FilePath.NewFilePath(rsp.DataFiles.DiscoveredUnitDTestsStore.Item)); var totalTests = testsPerAssembly.Values.Aggregate(0, (acc, e) => acc + e.Count); TelemetryClient.TrackEvent(rsi.name.Item, new Dictionary <string, string>(), new Dictionary <string, double> { { "TestCount", totalTests } }); return(rss.ToRSR(RunData.NewTestCases(testsPerAssembly), "Unit Tests Discovered - which ones - TBD")); }
private static PerDocumentLocationXTestCases GetTestToDebug(string discoveredUnitTestsStore, string discoveredUnitDTestsStore) { var discoveredUnitTests = PerDocumentLocationXTestCases.Deserialize(FilePath.NewFilePath(discoveredUnitTestsStore)); var discoveredUnitDTests = PerDocumentLocationDTestCases.Deserialize(FilePath.NewFilePath(discoveredUnitDTestsStore)); var dtc = discoveredUnitDTests.Values.First().First(); var dl = new DocumentLocation(dtc.CodeFilePath, dtc.LineNumber); var testToDebug = new PerDocumentLocationXTestCases(); testToDebug.TryAdd(dl, discoveredUnitTests[dl]); return(testToDebug); }
private static void DiscoverUnitTests(IEnumerable <IXTestDiscoverer> tds, string slnPath, string slnSnapPath, string discoveredUnitTestsStore, string discoveredUnitDTestsStore, string buildOutputRoot, DateTime timeFilter, string[] ignoredTests) { Logger.LogInfo("DiscoverUnitTests: starting discovering."); var testsPerAssembly = new PerDocumentLocationXTestCases(); var dtestsPerAssembly = new PerDocumentLocationDTestCases(); FindAndExecuteForEachAssembly( buildOutputRoot, timeFilter, (string assemblyPath) => { var disc = new XUnitTestDiscoverer(); disc.TestDiscovered.AddHandler( new FSharpHandler <XTestCase>( (o, ea) => { if (ea.CodeFilePath != null) { var cfp = PathBuilder.rebaseCodeFilePath(FilePath.NewFilePath(slnPath), FilePath.NewFilePath(slnSnapPath), FilePath.NewFilePath(ea.CodeFilePath)); ea.CodeFilePath = cfp.Item; } var dl = new DocumentLocation { document = FilePath.NewFilePath(ea.CodeFilePath), line = DocumentCoordinate.NewDocumentCoordinate(ea.LineNumber) }; var tests = testsPerAssembly.GetOrAdd(dl, _ => new ConcurrentBag <XTestCase>()); tests.Add(ea); var dtests = dtestsPerAssembly.GetOrAdd(dl, _ => new ConcurrentBag <DTestCase>()); dtests.Add(FromXTestCase(ea)); })); disc.DiscoverTests(tds, FilePath.NewFilePath(assemblyPath), ignoredTests); }); testsPerAssembly.Serialize(FilePath.NewFilePath(discoveredUnitTestsStore)); dtestsPerAssembly.Serialize(FilePath.NewFilePath(discoveredUnitDTestsStore)); Logger.LogInfo("Written discovered unit tests to {0} & {1}.", discoveredUnitTestsStore, discoveredUnitDTestsStore); }