public void EnableShutdownAfterTestRunShoudBeFalseByDefault() { var tec = GetTestExecutionContext(); var frameworkHandle = new FrameworkHandle(null, new TestRunCache(100, TimeSpan.MaxValue, (s, r, ip) => { }), tec, null); Assert.IsFalse(frameworkHandle.EnableShutdownAfterTestRun); }
private void SetContext() { this.testRunCache = new TestRunCache(this.testExecutionContext.FrequencyOfRunStatsChangeEvent, this.testExecutionContext.RunStatsChangeEventTimeout, this.OnCacheHit); this.runContext = new RunContext(); this.runContext.RunSettings = RunSettingsUtilities.CreateAndInitializeRunSettings(this.runSettings); this.runContext.KeepAlive = this.testExecutionContext.KeepAlive; this.runContext.InIsolation = this.testExecutionContext.InIsolation; this.runContext.IsDataCollectionEnabled = this.testExecutionContext.IsDataCollectionEnabled; this.runContext.IsBeingDebugged = this.testExecutionContext.IsDebug; var runConfig = XmlRunSettingsUtilities.GetRunConfigurationNode(this.runSettings); this.runContext.TestRunDirectory = RunSettingsUtilities.GetTestResultsDirectory(runConfig); this.runContext.SolutionDirectory = RunSettingsUtilities.GetSolutionDirectory(runConfig); this.runConfiguration = runConfig; this.frameworkHandle = new FrameworkHandle( this.testCaseEventsHandler, this.testRunCache, this.testExecutionContext, this.testRunEventsHandler); this.frameworkHandle.TestRunMessage += this.OnTestRunMessage; this.executorUrisThatRanTests = new List <string>(); }
public void LaunchProcessWithDebuggerAttachedShouldThrowIfObjectIsDisposed() { var tec = GetTestExecutionContext(); var frameworkHandle = new FrameworkHandle(null, new TestRunCache(100, TimeSpan.MaxValue, (s, r, ip) => { }), tec, null); frameworkHandle.Dispose(); Assert.ThrowsException <ObjectDisposedException>(() => frameworkHandle.LaunchProcessWithDebuggerAttached(null, null, null, null)); }
public void EnableShutdownAfterTestRunShoudBeSetAppropriately() { var tec = GetTestExecutionContext(); var frameworkHandle = new FrameworkHandle(null, new TestRunCache(100, TimeSpan.MaxValue, (s, r, ip) => { }), tec, null); frameworkHandle.EnableShutdownAfterTestRun = true; Assert.IsTrue(frameworkHandle.EnableShutdownAfterTestRun); }
private void ReportTestResult(Model.TestResult testResult) { Microsoft.VisualStudio.TestPlatform.ObjectModel.TestResult result = testResult.ToVsTestResult(); Throttle.Execute(delegate { // This is part of a workaround for a Visual Studio bug. See above. FrameworkHandle.RecordResult(result); }); FrameworkHandle.RecordEnd(result.TestCase, result.Outcome); }
public void ReportTestsStarted(IEnumerable <Model.TestCase> testCases) { lock (Lock) { foreach (TestCase testCase in testCases) { FrameworkHandle.RecordStart(DataConversionExtensions.ToVsTestCase(testCase)); } } }
public void LaunchProcessWithDebuggerAttachedShouldCallRunEventsHandler() { var tec = GetTestExecutionContext(); tec.IsDebug = true; var mockTestRunEventsHandler = new Mock <ITestRunEventsHandler>(); var frameworkHandle = new FrameworkHandle( null, new TestRunCache(100, TimeSpan.MaxValue, (s, r, ip) => { }), tec, mockTestRunEventsHandler.Object); frameworkHandle.LaunchProcessWithDebuggerAttached(null, null, null, null); mockTestRunEventsHandler.Verify(mt => mt.LaunchProcessWithDebuggerAttached(It.IsAny <TestProcessStartInfo>()), Times.Once); }
private void SetContext() { this.testRunCache = new TestRunCache(this.testExecutionContext.FrequencyOfRunStatsChangeEvent, testExecutionContext.RunStatsChangeEventTimeout, this.OnCacheHit); this.dataCollectionTestCaseEventManager = new DataCollectionTestCaseEventManager(testRunCache); this.inProcDataCollectionExtensionManager = new InProcDataCollectionExtensionManager(runSettings, testRunCache, this.dataCollectionTestCaseEventManager); if (DataCollectionTestCaseEventSender.Instance != null) { this.outOfProcDataCollectionManager = new ProxyOutOfProcDataCollectionManager(DataCollectionTestCaseEventSender.Instance, this.dataCollectionTestCaseEventManager); } if (!inProcDataCollectionExtensionManager.IsInProcDataCollectionEnabled) { // No need to call any methods on this, if inproc-datacollection is not enabled inProcDataCollectionExtensionManager = null; } if (inProcDataCollectionExtensionManager != null || DataCollectionTestCaseEventSender.Instance != null) { this.testCaseEventsHandler = new TestCaseEventsHandler(this.dataCollectionTestCaseEventManager, this.testCaseEventsHandler); } this.runContext = new RunContext(); this.runContext.RunSettings = RunSettingsUtilities.CreateAndInitializeRunSettings(this.runSettings); this.runContext.KeepAlive = this.testExecutionContext.KeepAlive; this.runContext.InIsolation = this.testExecutionContext.InIsolation; this.runContext.IsDataCollectionEnabled = this.testExecutionContext.IsDataCollectionEnabled; this.runContext.IsBeingDebugged = this.testExecutionContext.IsDebug; var runConfig = XmlRunSettingsUtilities.GetRunConfigurationNode(this.runSettings); this.runContext.TestRunDirectory = RunSettingsUtilities.GetTestResultsDirectory(runConfig); this.runContext.SolutionDirectory = RunSettingsUtilities.GetSolutionDirectory(runConfig); this.frameworkHandle = new FrameworkHandle( this.testCaseEventsHandler, this.testRunCache, this.testExecutionContext, this.testRunEventsHandler); this.frameworkHandle.TestRunMessage += this.OnTestRunMessage; this.executorUrisThatRanTests = new List <string>(); }
// TODO: Enable method once we fix the "IsDebug" in TestExecutionContext // [TestMethod] public void LaunchProcessWithDebuggerAttachedShouldThrowIfNotInDebugContext() { var tec = GetTestExecutionContext(); var frameworkHandle = new FrameworkHandle(null, new TestRunCache(100, TimeSpan.MaxValue, (s, r, ip) => { }), tec, null); var isExceptionThrown = false; try { frameworkHandle.LaunchProcessWithDebuggerAttached(null, null, null, null); } catch (InvalidOperationException exception) { isExceptionThrown = true; Assert.AreEqual("This operation is not allowed in the context of a non-debug run.", exception.Message); } Assert.IsTrue(isExceptionThrown); }
private void SetContext() { this.testRunCache = new TestRunCache(this.testExecutionContext.FrequencyOfRunStatsChangeEvent, this.testExecutionContext.RunStatsChangeEventTimeout, this.OnCacheHit); // Initialize data collectors if declared in run settings. if (DataCollectionTestCaseEventSender.Instance != null && XmlRunSettingsUtilities.IsDataCollectionEnabled(this.runSettings)) { var outOfProcDataCollectionManager = new ProxyOutOfProcDataCollectionManager(DataCollectionTestCaseEventSender.Instance, this.testEventsPublisher); } if (XmlRunSettingsUtilities.IsInProcDataCollectionEnabled(this.runSettings)) { var inProcDataCollectionExtensionManager = new InProcDataCollectionExtensionManager(this.runSettings, this.testEventsPublisher); } this.runContext = new RunContext(); this.runContext.RunSettings = RunSettingsUtilities.CreateAndInitializeRunSettings(this.runSettings); this.runContext.KeepAlive = this.testExecutionContext.KeepAlive; this.runContext.InIsolation = this.testExecutionContext.InIsolation; this.runContext.IsDataCollectionEnabled = this.testExecutionContext.IsDataCollectionEnabled; this.runContext.IsBeingDebugged = this.testExecutionContext.IsDebug; var runConfig = XmlRunSettingsUtilities.GetRunConfigurationNode(this.runSettings); this.runContext.TestRunDirectory = RunSettingsUtilities.GetTestResultsDirectory(runConfig); this.runContext.SolutionDirectory = RunSettingsUtilities.GetSolutionDirectory(runConfig); this.runConfiguration = runConfig; this.frameworkHandle = new FrameworkHandle( this.testCaseEventsHandler, this.testRunCache, this.testExecutionContext, this.testRunEventsHandler); this.frameworkHandle.TestRunMessage += this.OnTestRunMessage; this.executorUrisThatRanTests = new List <string>(); }
private void SetContext() { this.testRunCache = new TestRunCache(testExecutionContext.FrequencyOfRunStatsChangeEvent, testExecutionContext.RunStatsChangeEventTimeout, this.OnCacheHit); this.inProcDataCollectionExtensionManager = new InProcDataCollectionExtensionManager(runSettings, testRunCache); // Verify if datacollection is enabled and wrap the testcasehandler around to get the events if (inProcDataCollectionExtensionManager.IsInProcDataCollectionEnabled) { this.testCaseEventsHandler = new TestCaseEventsHandler(inProcDataCollectionExtensionManager, this.testCaseEventsHandler); } else { // No need to call any methods on this, if inproc-datacollection is not enabled inProcDataCollectionExtensionManager = null; } this.runContext = new RunContext(); this.runContext.RunSettings = RunSettingsUtilities.CreateAndInitializeRunSettings(this.runSettings); this.runContext.KeepAlive = this.testExecutionContext.KeepAlive; this.runContext.InIsolation = this.testExecutionContext.InIsolation; this.runContext.IsDataCollectionEnabled = this.testExecutionContext.IsDataCollectionEnabled; this.runContext.IsBeingDebugged = this.testExecutionContext.IsDebug; var runConfig = XmlRunSettingsUtilities.GetRunConfigurationNode(this.runSettings); this.runContext.TestRunDirectory = RunSettingsUtilities.GetTestResultsDirectory(runConfig); this.runContext.SolutionDirectory = RunSettingsUtilities.GetSolutionDirectory(runConfig); this.frameworkHandle = new FrameworkHandle( this.testCaseEventsHandler, this.testRunCache, this.testExecutionContext, this.testRunEventsHandler); this.executorUrisThatRanTests = new List <string>(); }