private Dictionary <string, ICollection <IMemberDefinition> > InstrumentAndSelect(IEnumerable <string> programModules, IEnumerable <string> testModules) { AnalyzerParameters analyzerParameters = new AnalyzerParameters(args.DependencyCollectionGranularity, !args.NoSmartChecksums); Analyzer analyzer = args.TestingFramework.GetAnalyzer(analyzerParameters); analysisStopwatch = new Stopwatch(); analysisStopwatch.Start(); Dictionary <string, ICollection <IMemberDefinition> > moduleToAffectedTests = analyzer.Analyze(testModules, programModules); analysisStopwatch.Stop(); ModuleDefinition dependencyMonitorModule = CILTransformer.GetModuleDefinition(CommonPaths.DependencyMonitorDLLPath); InstrumentatorParameters instrumentatorParameters = new InstrumentatorParameters(dependencyMonitorModule, args.TestingFramework, args.InstrumentationStrategy, args.InstrumentationArgumentsType, args.InstrumentAtMethodBeginning); Instrumentator instrumentator = new Instrumentator(instrumentatorParameters); foreach (var modulePath in testModules) { string destination = Path.Combine(Path.GetDirectoryName(modulePath), "DependencyMonitor.dll"); File.Copy(CommonPaths.DependencyMonitorDLLPath, destination, true); string configuration = Path.Combine(Path.GetDirectoryName(modulePath), Paths.DependencyMonitorConfigurationFileName); File.WriteAllText(configuration, Paths.OutputDirectory); } instrumentationStopwatch = new Stopwatch(); instrumentationStopwatch.Start(); bool instrument = false; foreach (var tests in moduleToAffectedTests.Values) { if (tests.Any()) { // instruments if there are some tests to be run instrument = true; break; } } if (instrument) { instrumentator.Instrument(moduleToAffectedTests, programModules); } instrumentationStopwatch.Stop(); return(moduleToAffectedTests); }
public static TestInstrumentator GetTestInstrumentator(this TestingFrameworkType testingFramework, ModuleDefinition testModule, InstrumentatorParameters parameters) { switch (testingFramework) { case TestingFrameworkType.NUnit2: return(new NUnit2Instrumentator(testModule, parameters)); case TestingFrameworkType.NUnit3: return(new NUnit3Instrumentator(testModule, parameters)); case TestingFrameworkType.XUnit1: return(new XUnit1Instrumentator(testModule, parameters)); case TestingFrameworkType.XUnit2: return(new XUnit2Instrumentator(testModule, parameters)); default: throw new ArgumentOutOfRangeException(); } }