internal TestAssemblyViewModel(AssemblyRunInfo runInfo, ITestRunner runner) { RunInfo = runInfo; ; this.runner = runner; runAllTestsCommand = new DelegateCommand(RunAllTests, () => !isBusy); runFilteredTestsCommand = new DelegateCommand(RunFilteredTests, () => !isBusy); DisplayName = Path.GetFileNameWithoutExtension(runInfo.AssemblyFileName); allTests = new ObservableCollection <TestCaseViewModel>(runInfo.TestCases); filteredTests = new FilteredCollectionView <TestCaseViewModel, Tuple <string, TestState> >( allTests, IsTestFilterMatch, Tuple.Create(SearchQuery, ResultFilter), new TestComparer() ); filteredTests.ItemChanged += (sender, args) => UpdateCaption(); filteredTests.CollectionChanged += (sender, args) => UpdateCaption(); Result = TestState.NotRun; RunStatus = RunStatus.NotRun; UpdateCaption(); }
void RunTestsInAssembly(List <IDisposable> toDispose, AssemblyRunInfo runInfo) { if (cancelled) { return; } var assemblyFileName = runInfo.AssemblyFileName; var controller = new XunitFrontController(AppDomainSupport.Denied, assemblyFileName); lock (toDispose) toDispose.Add(controller); var xunitTestCases = runInfo.TestCases.Select(tc => new { vm = tc, tc = tc.TestCase }) .Where(tc => tc.tc.UniqueID != null) .ToDictionary(tc => tc.tc, tc => tc.vm); var executionOptions = TestFrameworkOptions.ForExecution(runInfo.Configuration); using (var executionVisitor = new TestExecutionVisitor(xunitTestCases, this, executionOptions, () => cancelled, context)) { controller.RunTests(xunitTestCases.Select(tc => tc.Value.TestCase).ToList(), executionVisitor, executionOptions); executionVisitor.Finished.WaitOne(); } }
void RunTestsInAssembly(List <IDisposable> toDispose, AssemblyRunInfo runInfo) { if (cancelled) { return; } var assemblyFileName = runInfo.AssemblyFileName; var longRunningSeconds = runInfo.Configuration.LongRunningTestSecondsOrDefault; var controller = new XunitFrontController(AppDomainSupport.Denied, assemblyFileName); lock (toDispose) toDispose.Add(controller); var xunitTestCases = runInfo.TestCases.Select(tc => new { vm = tc, tc = tc.TestCase }) .Where(tc => tc.tc.UniqueID != null) .ToDictionary(tc => tc.tc, tc => tc.vm); var executionOptions = TestFrameworkOptions.ForExecution(runInfo.Configuration); var diagSink = new DiagnosticMessageSink(d => context.Post(_ => OnDiagnosticMessage?.Invoke(d), null), runInfo.AssemblyFileName, executionOptions.GetDiagnosticMessagesOrDefault()); var deviceExecSink = new DeviceExecutionSink(xunitTestCases, this, context); IExecutionSink resultsSink = new DelegatingExecutionSummarySink(deviceExecSink, () => cancelled); if (longRunningSeconds > 0) { resultsSink = new DelegatingLongRunningTestDetectionSink(resultsSink, TimeSpan.FromSeconds(longRunningSeconds), diagSink); } var assm = new XunitProjectAssembly() { AssemblyFilename = runInfo.AssemblyFileName }; deviceExecSink.OnMessage(new TestAssemblyExecutionStarting(assm, executionOptions)); controller.RunTests(xunitTestCases.Select(tc => tc.Value.TestCase).ToList(), resultsSink, executionOptions); resultsSink.Finished.WaitOne(); deviceExecSink.OnMessage(new TestAssemblyExecutionFinished(assm, executionOptions, resultsSink.ExecutionSummary)); }
ManualResetEvent RunTestsInAssemblyAsync(List <IDisposable> toDispose, AssemblyRunInfo runInfo) { var @event = new ManualResetEvent(false); void Handler() { try { RunTestsInAssembly(toDispose, runInfo); } finally { @event.Set(); } } ThreadPoolHelper.RunAsync(Handler); return(@event); }
ManualResetEvent RunTestsInAssemblyAsync(List<IDisposable> toDispose, AssemblyRunInfo runInfo) { var @event = new ManualResetEvent(false); Action handler = () => { try { RunTestsInAssembly(toDispose, runInfo); } finally { @event.Set(); } }; ThreadPoolHelper.RunAsync(handler); return @event; }
void RunTestsInAssembly(List<IDisposable> toDispose, AssemblyRunInfo runInfo) { if (cancelled) return; var assemblyFileName = runInfo.AssemblyFileName; var controller = new XunitFrontController(AppDomainSupport.Denied, assemblyFileName); lock (toDispose) toDispose.Add(controller); var xunitTestCases = runInfo.TestCases.Select(tc => new { vm = tc, tc = tc.TestCase }) .Where(tc => tc.tc.UniqueID != null) .ToDictionary(tc => tc.tc, tc => tc.vm); var executionOptions = TestFrameworkOptions.ForExecution(runInfo.Configuration); using (var executionVisitor = new TestExecutionVisitor(xunitTestCases, this, executionOptions, () => cancelled, context)) { controller.RunTests(xunitTestCases.Select(tc => tc.Value.TestCase).ToList(), executionVisitor, executionOptions); executionVisitor.Finished.WaitOne(); } }