private void SetupMockTimeOutTestRun(Mock <IVsTestConsoleWrapper> mockVsTest, IReadOnlyDictionary <string, string> results, string timeoutTest, EventWaitHandle endProcess) { mockVsTest.Setup(x => x.RunTestsWithCustomTestHost( It.IsAny <IEnumerable <TestCase> >(), It.IsAny <string>(), It.IsAny <ITestRunEventsHandler>(), It.IsAny <ITestHostLauncher>())).Callback( (IEnumerable <TestCase> sources, string settings, ITestRunEventsHandler testRunEvents, ITestHostLauncher host) => { var collector = new CoverageCollector(); var start = new TestSessionStartArgs { Configuration = settings }; var mock = new Mock <IDataCollectionSink>(MockBehavior.Loose); TestCase timeOutTestCase = null; collector.Initialize(mock.Object); collector.TestSessionStart(start); var mutants = collector.MutantList; if (!results.ContainsKey(mutants)) { throw new ArgumentException($"Unexpected mutant run {mutants}"); } var tests = sources.ToList(); var data = results[mutants].Split(',').Select(e => e.Split('=')).ToList(); if (data.Count != tests.Count) { throw new ArgumentException($"Invalid number of tests for mutant run {mutants}: found {tests.Count}, expected {data.Count}"); } var runResults = new List <TestResult>(data.Count); foreach (var strings in data) { var matchingTest = tests.FirstOrDefault(t => t.FullyQualifiedName == strings[0]); if (matchingTest == null) { throw new ArgumentException($"Test {strings[0]} not run for mutant {mutants}."); } if (matchingTest.FullyQualifiedName == timeoutTest) { timeOutTestCase = matchingTest; } var result = new TestResult(matchingTest) { Outcome = strings[1] == "F" ? TestOutcome.Failed : TestOutcome.Passed, ComputerName = "." }; runResults.Add(result); } // setup a normal test run MoqTestRun(testRunEvents, runResults, timeOutTestCase); collector.TestSessionEnd(new TestSessionEndArgs()); endProcess.Set(); }); }
/// <summary> /// The trigger session start. /// </summary> public virtual void TriggerTestSessionStart() { this.testCaseEndStatusMap.Clear(); this.testResultDictionary.Clear(); TestSessionStartArgs testSessionStartArgs = new TestSessionStartArgs(); this.TriggerInProcDataCollectionMethods(Constants.TestSessionStartMethodName, testSessionStartArgs); }
/// <summary> /// The test session start. /// </summary> /// <param name="testSessionStartArgs"> /// The test session start args. /// </param> public void TestSessionStart(TestSessionStartArgs testSessionStartArgs) { Console.WriteLine(testSessionStartArgs.Configuration); File.WriteAllText(this.fileName, "TestSessionStart : " + testSessionStartArgs.Configuration + "\r\n"); #if NETFRAMEWORK var appDomainFilePath = Path.Combine(Path.GetTempPath(), "appdomain_datacollector.txt"); File.WriteAllText(appDomainFilePath, "AppDomain FriendlyName: " + AppDomain.CurrentDomain.FriendlyName); #endif }
public void TestSessionStart(TestSessionStartArgs testSessionStartArgs) { var coverageString = Environment.GetEnvironmentVariable(ModeEnvironmentVariable); _coverageOn = coverageString != null; _usePipe = (coverageString == PipeMode); foreach (var environmentVariable in GetEnvironmentVariables()) { Environment.SetEnvironmentVariable(environmentVariable.Key, environmentVariable.Value); } Log($"Test Session start with conf {testSessionStartArgs.Configuration}."); }
public void ProperlyCaptureParams() { var collector = new CoverageCollector(); var start = new TestSessionStartArgs { Configuration = CoverageCollector.GetVsTestSettings(true, null, "Stryker.Core.UnitTest.TestRunners") }; var mock = new Mock <IDataCollectionSink>(MockBehavior.Loose); collector.Initialize(mock.Object); collector.TestSessionStart(start); collector.TestCaseStart(new TestCaseStartArgs(new TestCase("theTest", new Uri("xunit://"), "source.cs"))); MutantControl.CaptureCoverage.ShouldBeTrue(); }
// called before any test is run public void TestSessionStart(TestSessionStartArgs testSessionStartArgs) { var configuration = testSessionStartArgs.Configuration; ReadConfiguration(configuration); // scan loaded assembly, just in case the test assembly is already loaded var assemblies = AppDomain.CurrentDomain.GetAssemblies().Where(assembly => !assembly.IsDynamic); foreach (var assembly in assemblies) { FindControlType(assembly); } AppDomain.CurrentDomain.AssemblyLoad += OnAssemblyLoaded; Log($"Test Session start with conf {configuration}."); }
public void ProperlySelectMutant() { var collector = new CoverageCollector(); var mutantMap = new Dictionary <int, IList <string> >() { [0] = new List <string>() }; var start = new TestSessionStartArgs { Configuration = CoverageCollector.GetVsTestSettings(false, mutantMap, this.GetType().Namespace) }; var mock = new Mock <IDataCollectionSink>(MockBehavior.Loose); collector.Initialize(mock.Object); collector.TestSessionStart(start); collector.TestCaseStart(new TestCaseStartArgs(new TestCase("theTest", new Uri("xunit://"), "source.cs"))); MutantControl.ActiveMutant.ShouldBe(0); }
/// <summary> /// The trigger test session start. /// </summary> /// <param name="sender"> /// The sender. /// </param> /// <param name="e"> /// The e. /// </param> private void TriggerTestSessionStart(object sender, SessionStartEventArgs e) { TestSessionStartArgs testSessionStartArgs = new TestSessionStartArgs(); this.TriggerInProcDataCollectionMethods(Constants.TestSessionStartMethodName, testSessionStartArgs); }
public void TestSessionStart(TestSessionStartArgs _testSessionStartArgs) { Debug.WriteLine("TestSessionStart"); Supervise(); }
public void TestSessionStart(TestSessionStartArgs testSessionStartArgs) { }
/// <summary> /// The test session start. /// </summary> /// <param name="testSessionStartArgs"> /// The test session start args. /// </param> public void TestSessionStart(TestSessionStartArgs testSessionStartArgs) { Console.WriteLine(testSessionStartArgs.Configuration); File.WriteAllText(this.fileName, "TestSessionStart : " + testSessionStartArgs.Configuration + Environment.NewLine); }
private void TestSessionStartMethodCalled(TestSessionStartArgs testSessionStartArgs) { TestSessionStartCalled++; this.TestSources = testSessionStartArgs.GetPropertyValue <IEnumerable <string> >("TestSources"); }
public void TestSessionStart(TestSessionStartArgs testSessionStartArgs) { throw new System.NotImplementedException(); }
public void TestSessionStart(TestSessionStartArgs testSessionStartArgs) { Debug.WriteLine("TestSessionStart : {0}", testSessionStartArgs); Supervise(); }