public VsTestRunner( StrykerOptions options, OptimizationFlags flags, ProjectInfo projectInfo, ICollection <TestCase> testCasesDiscovered, IFileSystem fileSystem = null, IVsTestHelper helper = null, ILogger logger = null, IVsTestConsoleWrapper wrapper = null, Func <int, IStrykerTestHostLauncher> hostBuilder = null) { _logger = logger ?? ApplicationLogging.LoggerFactory.CreateLogger <VsTestRunner>(); _fileSystem = fileSystem ?? new FileSystem(); _options = options; _flags = flags; _projectInfo = projectInfo; _hostBuilder = hostBuilder ?? ((id) => new StrykerVsTestHostLauncher(id)); SetListOfTests(testCasesDiscovered); _ownHelper = helper == null; _vsTestHelper = helper ?? new VsTestHelper(); _vsTestConsole = wrapper ?? PrepareVsTestConsole(); _id = _count++; if (testCasesDiscovered != null) { _discoveredTests = testCasesDiscovered; DetectTestFramework(testCasesDiscovered); } InitializeVsTestConsole(); }
public VsTestRunner( StrykerOptions options, OptimizationFlags flags, ProjectInfo projectInfo, ICollection <TestCase> testCasesDiscovered, TestCoverageInfos mappingInfos, IFileSystem fileSystem = null, IVsTestHelper helper = null, ILogger logger = null, IVsTestConsoleWrapper wrapper = null, Func <IDictionary <string, string>, int, IStrykerTestHostLauncher> hostBuilder = null) { _logger = logger ?? ApplicationLogging.LoggerFactory.CreateLogger <VsTestRunner>(); _fileSystem = fileSystem ?? new FileSystem(); _options = options; _flags = flags; _projectInfo = projectInfo; _hostBuilder = hostBuilder ?? ((dico, id) => new StrykerVsTestHostLauncher(dico, id)); SetListOfTests(testCasesDiscovered); _ownHelper = helper == null; _vsTestHelper = helper ?? new VsTestHelper(); CoverageMutants = mappingInfos ?? new TestCoverageInfos(); _vsTestConsole = wrapper ?? PrepareVsTestConsole(); _id = _count++; if (testCasesDiscovered != null) { _discoveredTests = testCasesDiscovered; DetectTestFramework(testCasesDiscovered); } InitializeVsTestConsole(); _coverageEnvironment = new Dictionary <string, string> { { CoverageCollector.ModeEnvironmentVariable, flags.HasFlag(OptimizationFlags.UseEnvVariable) ? CoverageCollector.EnvMode : CoverageCollector.PipeMode } }; }
public DotnetTestRunner(string path, IProcessExecutor processProxy, ITotalNumberOfTestsParser totalNumberOfTestsParser, OptimizationFlags flags) { _totalNumberOfTestsParser = totalNumberOfTestsParser; _flags = flags; Path = path; ProcessExecutor = processProxy; CoverageMutants = new TestCoverageInfos(); }
public DotnetTestRunner(string path, IProcessExecutor processProxy, OptimizationFlags flags, IEnumerable<string> testBinariesPaths) { _logger = ApplicationLogging.LoggerFactory.CreateLogger<DotnetTestRunner>(); _flags = flags; _projectFile = path; _processExecutor = processProxy; CoverageMutants = new TestCoverageInfos(); _testBinariesPaths = testBinariesPaths; }
public DotnetTestRunner(string path, IProcessExecutor processProxy, OptimizationFlags flags, ILogger logger = null) { _logger = logger ?? ApplicationLogging.LoggerFactory.CreateLogger <DotnetTestRunner>(); _flags = flags; _path = Path.GetDirectoryName(FilePathUtils.ConvertPathSeparators(path)); _processExecutor = processProxy; CoverageMutants = new TestCoverageInfos(); }
/// <summary> /// Serialize the object. /// </summary> /// <param name="data">Data carrier to serialize to</param> /// <param name="target">Object or root of object model to be serialized</param> /// <exception cref="ArgumentNullException">thrown if <paramref name="data"/> is null or <paramref name="target"/> is null</exception> public void SerializeObject <TTarget>(IDataAdapter data, TTarget target) { if (data == null) { throw new ArgumentNullException(nameof(data)); } if (target == null) { throw new ArgumentNullException(nameof(target)); } haveContainers = false; haveReferences = false; havePrivateProperties = false; SerializeSubValue(typeof(TTarget), target, data, null); if (!settings.SaveOptimizationFlags) { return; } OptimizationFlags flags = 0; if (!haveContainers) { flags |= OptimizationFlags.NoContainers; } if (!haveReferences) { flags |= OptimizationFlags.NoReferences; } if (havePrivateProperties) { flags |= OptimizationFlags.PrivateProperties; } if (settings.EnumsAsValue) { flags |= OptimizationFlags.EnumAsValue; } if (flags != 0) { data.AddIntValue((long)flags, ATTRIBUTE_FLAGS, true); } if (typesCache.Count > 0) { IDataArray array = data.AddChild(ELEMENT_TYPES).AddArray(); foreach (KeyValuePair <Type, int> pair in typesCache) { array.AddArrayValue().SetStringValue(TypeCache.GetTypeFullName(pair.Key, settings.AssemblyQualifiedNames)); } } }
public DotnetTestRunner(string path, IProcessExecutor processProxy, OptimizationFlags flags, IEnumerable <string> testBinariesPaths) { _logger = ApplicationLogging.LoggerFactory.CreateLogger <DotnetTestRunner>(); _flags = flags; _projectFile = FilePathUtils.NormalizePathSeparators(path); _processExecutor = processProxy; _testBinariesPaths = testBinariesPaths; _server = new CommunicationServer("CoverageCollector"); _server.SetLogger((msg) => _logger.LogDebug(msg)); _server.RaiseNewClientEvent += ConnectionEstablished; _server.Listen(); }
public VsTestRunnerPool(StrykerOptions options, OptimizationFlags flags, ProjectInfo projectInfo) { _flags = flags; using (var runner = new VsTestRunner(options, _flags, projectInfo, null, null)) { _discoveredTests = runner.DiscoverTests(); } Parallel.For(0, options.ConcurrentTestrunners, (i, loopState) => { _availableRunners.Enqueue(new VsTestRunner(options, _flags, projectInfo, _discoveredTests, _coverage, helper: _helper)); }); }
private StrykerOptions( string basePath, string outputPath, IEnumerable <Reporter> reporters, string projectUnderTestNameFilter, string projectUnderTest, int additionalTimeoutMS, IEnumerable <Mutator> excludedMutations, IEnumerable <Regex> ignoredMethods, LogOptions logOptions, OptimizationFlags optimizations, Threshold thresholds, bool devMode, string optimizationMode, int concurrentTestRunners, IEnumerable <FilePattern> filePatterns, TestRunner testRunner, string solutionPath, LanguageVersion languageVersion, string gitDiffSource, IEnumerable <string> testProjects, string azureSAS, string azureFileStorageUrl, BaselineProvider baselineProvider, MutationLevel mutationLevel) { IgnoredMethods = ignoredMethods; BasePath = basePath; OutputPath = outputPath; Reporters = reporters; ProjectUnderTestNameFilter = projectUnderTestNameFilter; ProjectUnderTest = projectUnderTest; AdditionalTimeoutMS = additionalTimeoutMS; ExcludedMutations = excludedMutations; LogOptions = logOptions; DevMode = devMode; ConcurrentTestrunners = concurrentTestRunners; Thresholds = thresholds; FilePatterns = filePatterns; TestRunner = testRunner; SolutionPath = solutionPath; LanguageVersion = languageVersion; OptimizationMode = optimizationMode; Optimizations = optimizations; GitDiffTarget = gitDiffSource; TestProjects = testProjects; AzureSAS = azureSAS; AzureFileStorageUrl = azureFileStorageUrl; BaselineProvider = baselineProvider; MutationLevel = mutationLevel; }
public VsTestRunnerPool(StrykerOptions options, OptimizationFlags flags, ProjectInfo projectInfo) { _logger = ApplicationLogging.LoggerFactory.CreateLogger <VsTestRunnerPool>(); _flags = flags; using (var runner = new VsTestRunner(options, _flags, projectInfo, null, null)) { _discoveredTests = runner.DiscoverTests(); } Parallel.For(0, options.ConcurrentTestrunners, (i, loopState) => { _availableRunners.Add(new VsTestRunner(options, _flags, projectInfo, _discoveredTests, CoverageMutants, helper: _helper)); }); }
public ITestRunner Create(IStrykerOptions options, OptimizationFlags flags, ProjectInfo projectInfo) { _logger.LogInformation("Initializing test runners ({0})", options.TestRunner); ITestRunner testRunner; switch (options.TestRunner) { case TestRunner.DotnetTest: default: testRunner = new DotnetTestRunner(projectInfo.ProjectUnderTestAnalyzerResult.ProjectFilePath, new ProcessExecutor(), flags, projectInfo.TestProjectAnalyzerResults.Select(x => x.GetAssemblyPath())); break; case TestRunner.VsTest: testRunner = new VsTestRunnerPool(options, flags, projectInfo); break; } return(testRunner); }
public ITestRunner Create(StrykerOptions options, OptimizationFlags flags, ProjectInfo projectInfo) { Logger.LogDebug("Factory is creating testrunner for asked type {0}", options.TestRunner); ITestRunner testRunner = null; switch (options.TestRunner) { case TestRunner.DotnetTest: default: testRunner = new DotnetTestRunner(options.BasePath, new ProcessExecutor(), new TotalNumberOfTestsParser(), flags); break; case TestRunner.VsTest: testRunner = new VsTestRunnerPool(options, flags, projectInfo); break; } Logger.LogInformation("Using testrunner {0}", options.TestRunner.ToString()); return(testRunner); }
public StrykerOptions( IFileSystem fileSystem = null, string basePath = "", string[] reporters = null, string projectUnderTestNameFilter = "", string testProjectNameFilter = "*.csproj", int additionalTimeoutMS = 5000, string[] excludedMutations = null, string logLevel = "info", bool logToFile = false, bool devMode = false, string coverageAnalysis = "", bool abortTestOnFail = false, int maxConcurrentTestRunners = int.MaxValue, int thresholdHigh = 80, int thresholdLow = 60, int thresholdBreak = 0, string[] filesToExclude = null, string testRunner = "vstest", string solutionPath = null, string languageVersion = "latest") { _fileSystem = fileSystem ?? new FileSystem(); var outputPath = ValidateOutputPath(basePath); BasePath = basePath; OutputPath = outputPath; Reporters = ValidateReporters(reporters); ProjectUnderTestNameFilter = projectUnderTestNameFilter; TestProjectNameFilter = ValidateTestProjectFilter(basePath, testProjectNameFilter); AdditionalTimeoutMS = additionalTimeoutMS; ExcludedMutations = ValidateExludedMutations(excludedMutations); LogOptions = new LogOptions(ValidateLogLevel(logLevel), logToFile, outputPath); DevMode = devMode; ConcurrentTestrunners = ValidateConcurrentTestrunners(maxConcurrentTestRunners); Optimizations = ValidateMode(coverageAnalysis) | (abortTestOnFail ? OptimizationFlags.AbortTestOnKill : OptimizationFlags.NoOptimization); Thresholds = ValidateThresholds(thresholdHigh, thresholdLow, thresholdBreak); FilesToExclude = ValidateFilesToExclude(filesToExclude); TestRunner = ValidateTestRunner(testRunner); SolutionPath = ValidateSolutionPath(basePath, solutionPath); LanguageVersion = ValidateLanguageVersion(languageVersion); }
public ITestRunner Create(StrykerOptions options, OptimizationFlags flags, ProjectInfo projectInfo) { _logger.LogDebug("Factory is creating testrunner for asked type {0}", options.TestRunner); ITestRunner testRunner; switch (options.TestRunner) { case TestRunner.DotnetTest: default: testRunner = new DotnetTestRunner(projectInfo.ProjectUnderTestAnalyzerResult.ProjectFilePath, new ProcessExecutor(), flags, projectInfo.TestProjectAnalyzerResults.Select(x => projectInfo.GetTestBinariesPath(x))); break; case TestRunner.VsTest: testRunner = new VsTestRunnerPool(options, flags, projectInfo); break; } _logger.LogInformation("Using testrunner {0}", options.TestRunner.ToString()); return(testRunner); }
public VsTestRunner(StrykerOptions options, OptimizationFlags flags, ProjectInfo projectInfo, ICollection <TestCase> testCasesDiscovered, TestCoverageInfos mappingInfos, IFileSystem fileSystem = null, VsTestHelper helper = null) { _fileSystem = fileSystem ?? new FileSystem(); _options = options; _flags = flags; _projectInfo = projectInfo; SetListOfTests(testCasesDiscovered); _ownHelper = helper == null; _vsTestHelper = helper ?? new VsTestHelper(); CoverageMutants = mappingInfos ?? new TestCoverageInfos(); _vsTestConsole = PrepareVsTestConsole(); _id = _count++; InitializeVsTestConsole(); _coverageEnvironment = new Dictionary <string, string> { { CoverageCollector.ModeEnvironmentVariable, flags.HasFlag(OptimizationFlags.UseEnvVariable) ? CoverageCollector.EnvMode : CoverageCollector.PipeMode } }; }
private Mock <IVsTestConsoleWrapper> BuildVsTestRunner(IStrykerOptions options, WaitHandle endProcess, out VsTestRunner runner, OptimizationFlags optimizationFlags) { var mockVsTest = new Mock <IVsTestConsoleWrapper>(MockBehavior.Strict); mockVsTest.Setup(x => x.StartSession()); mockVsTest.Setup(x => x.InitializeExtensions(It.IsAny <List <string> >())); mockVsTest.Setup(x => x.AbortTestRun()); mockVsTest.Setup(x => x.DiscoverTests(It.Is <IEnumerable <string> >(d => d.Any(e => e == _testAssemblyPath)), It.IsAny <string>(), It.IsAny <ITestDiscoveryEventsHandler>())).Callback( (IEnumerable <string> sources, string discoverySettings, ITestDiscoveryEventsHandler discoveryEventsHandler) => DiscoverTests(sources, discoverySettings, discoveryEventsHandler, _testCases, false)); runner = new VsTestRunner( options, optimizationFlags, _targetProject, null, _fileSystem, new Mock <IVsTestHelper>().Object, wrapper: mockVsTest.Object, hostBuilder: (i) => new MoqHost(endProcess)); return(mockVsTest); }
private StrykerOptions( IFileSystem fileSystem, ILogger logger, string basePath, string outputPath, IEnumerable <Reporter> reporters, string projectUnderTestNameFilter, string projectUnderTest, int additionalTimeoutMS, IEnumerable <Mutator> excludedMutations, IEnumerable <Regex> ignoredMethods, LogOptions logOptions, OptimizationFlags optimizations, Threshold thresholds, bool devMode, string optimizationMode, int concurrentTestRunners, IEnumerable <FilePattern> filePatterns, TestRunner testRunner, string solutionPath, LanguageVersion languageVersion, bool diffEnabled, string gitDiffSource, IEnumerable <FilePattern> diffIgnoreFiles, IEnumerable <string> testProjects, string azureSAS, string azureFileStorageUrl, BaselineProvider baselineProvider, MutationLevel mutationLevel, bool compareToDashboard, string dashboardUrl, string dashboardApiKey, string projectName, string moduleName, string projectVersion, string fallbackVersion) { _fileSystem = fileSystem; _logger = logger; IgnoredMethods = ignoredMethods; BasePath = basePath; OutputPath = outputPath; Reporters = reporters; ProjectUnderTestNameFilter = projectUnderTestNameFilter; ProjectUnderTest = projectUnderTest; AdditionalTimeoutMS = additionalTimeoutMS; ExcludedMutations = excludedMutations; LogOptions = logOptions; DevMode = devMode; ConcurrentTestrunners = concurrentTestRunners; Thresholds = thresholds; FilePatterns = filePatterns; TestRunner = testRunner; SolutionPath = solutionPath; LanguageVersion = languageVersion; OptimizationMode = optimizationMode; Optimizations = optimizations; DiffEnabled = diffEnabled; GitDiffSource = gitDiffSource; DiffIgnoreFiles = diffIgnoreFiles; TestProjects = testProjects; AzureSAS = azureSAS; AzureFileStorageUrl = azureFileStorageUrl; BaselineProvider = baselineProvider; MutationLevel = mutationLevel; CompareToDashboard = compareToDashboard; DashboardUrl = dashboardUrl; DashboardApiKey = dashboardApiKey; ProjectName = projectName; ModuleName = moduleName; ProjectVersion = projectVersion; FallbackVersion = fallbackVersion; }
private Mock <IVsTestConsoleWrapper> BuildVsTestRunner(StrykerOptions options, EventWaitHandle endProcess, out VsTestRunner runner, OptimizationFlags optimizationFlags) { var mockVsTest = BuildVsTestMock(options); runner = new VsTestRunner( options, optimizationFlags, _targetProject, null, null, _fileSystem, helper: new Mock <IVsTestHelper>().Object, wrapper: mockVsTest.Object, hostBuilder: ((dictionary, i) => new MoqHost(endProcess, dictionary, i))); return(mockVsTest); }