public async Task Instrument(TModel toInstrument, IList <MSTestTestcase> tests, CancellationToken token) { dependencyMonitorModule = ModuleDefinition.ReadModule(Path.GetFullPath($"{MonitorAssemblyName}.dll")); dependencyMonitorType = dependencyMonitorModule.Types.Single(x => x.FullName == DependencyMonitorClassFullName); testMethodStartedReference = dependencyMonitorType.Methods.Single(x => x.FullName == TestMethodStartFullName); testMethodNameReference = dependencyMonitorType.Methods.Single(x => x.FullName == TestMethodNameFullName); testMethodEndReference = dependencyMonitorType.Methods.Single(x => x.FullName == TestMethodEndFullName); typeVisitedMethodReference = dependencyMonitorType.Methods.Single(x => x.FullName == TypeMethodFullName); testAssemblies = tests.Select(x => x.AssemblyPath).Distinct().ToList(); var parsingResult = await assembliesAdapter.Parse(toInstrument.AbsoluteSolutionPath, token); assemblies = parsingResult.Select(x => x.AbsolutePath).ToList(); assemblyNames = assemblies.Select(Path.GetFileName).ToList(); msTestTestcases = tests; testNamesToExecutionIds = tests.Select(x => new Tuple <string, int>(x.Id, tests.IndexOf(x))).ToList(); loggingHelper.ReportNeededTime(() => InstrumentProgramAssemblies(token), "Instrumenting Program Assemblies"); loggingHelper.ReportNeededTime(() => InstrumentTestAssemblies(token), "Instrumenting Test Assemblies"); }
public virtual async Task <TResult> ExecuteRTSRun(TProgramDelta programDelta, CancellationToken token) { var testsDelta = await loggingHelper.ReportNeededTime(() => testsDeltaAdapter.GetTestsDelta(programDelta, FilterFunction, token), "Tests Discovery"); token.ThrowIfCancellationRequested(); await loggingHelper.ReportNeededTime(() => testSelector.SelectTests(testsDelta, programDelta, token), "Tests Selection"); var impactedTests = testSelector.SelectedTests; foreach (var impactedTest in impactedTests) { token.ThrowIfCancellationRequested(); ImpactedTest?.Invoke(this, new ImpactedTestEventArgs <TTestCase>(impactedTest, responsibleChangesReporter.GetResponsibleChanges(testSelector.CorrespondenceModel, impactedTest, programDelta))); } loggingHelper.WriteMessage($"{impactedTests.Count} Tests impacted"); var prioritizedTests = await loggingHelper.ReportNeededTime(() => testPrioritizer.PrioritizeTests(impactedTests, token), "Tests Prioritization"); TestsPrioritized?.Invoke(this, new TestsPrioritizedEventArgs <TTestCase>(prioritizedTests)); var executor = testProcessor as ITestExecutor <TTestCase, TProgramDelta, TProgram>; if (executor != null) { executor.TestResultAvailable += TestResultAvailable; } var processingResult = await loggingHelper.ReportNeededTime(() => testProcessor.ProcessTests(prioritizedTests, testsDelta, programDelta, token), "Tests Processing"); if (executor != null) { executor.TestResultAvailable -= TestResultAvailable; } return(processingResult); }