/// <summary> /// Default constructor. /// </summary> /// <param name="stats">The final stats for the test run. This parameter is only set for communications between the test host and the clients (like VS)</param> /// <param name="isCanceled">Specifies whether the test run is canceled.</param> /// <param name="isAborted">Specifies whether the test run is aborted.</param> /// <param name="error">Specifies the error encountered during the execution of the test run.</param> /// <param name="attachmentSets">Attachment sets associated with the run.</param> /// <param name="elapsedTime">Time elapsed in just running tests</param> public TestRunCompleteEventArgs(ITestRunStatistics stats, bool isCanceled, bool isAborted, Exception error, Collection <AttachmentSet> attachmentSets, TimeSpan elapsedTime) { this.TestRunStatistics = stats; this.IsCanceled = isCanceled; this.IsAborted = isAborted; this.Error = error; this.AttachmentSets = attachmentSets; this.ElapsedTimeInRunningTests = elapsedTime; }
/// <summary> /// Default constructor. /// </summary> /// <param name="stats">The final stats for the test run. This parameter is only set for communications between the test host and the clients (like VS)</param> /// <param name="isCanceled">Specifies whether the test run is canceled.</param> /// <param name="isAborted">Specifies whether the test run is aborted.</param> /// <param name="error">Specifies the error encountered during the execution of the test run.</param> /// <param name="attachmentSets">Attachment sets associated with the run.</param> /// <param name="elapsedTime">Time elapsed in just running tests</param> public TestRunCompleteEventArgs(ITestRunStatistics stats, bool isCanceled, bool isAborted, Exception error, Collection <AttachmentSet> attachmentSets, TimeSpan elapsedTime) { this.TestRunStatistics = stats; this.IsCanceled = isCanceled; this.IsAborted = isAborted; this.Error = null; // Passing error value as null, should be pass exception. Issue: https://github.com/Microsoft/vstest/issues/618 this.AttachmentSets = attachmentSets; this.ElapsedTimeInRunningTests = elapsedTime; }
/// <summary> /// Default constructor. /// </summary> /// <param name="stats">The final stats for the test run. This parameter is only set for communications between the test host and the clients (like VS)</param> /// <param name="isCanceled">Specifies whether the test run is canceled.</param> /// <param name="isAborted">Specifies whether the test run is aborted.</param> /// <param name="error">Specifies the error encountered during the execution of the test run.</param> /// <param name="attachmentSets">Attachment sets associated with the run.</param> /// <param name="elapsedTime">Time elapsed in just running tests</param> public TestRunCompleteEventArgs(ITestRunStatistics stats, bool isCanceled, bool isAborted, Exception error, Collection <AttachmentSet> attachmentSets, TimeSpan elapsedTime) { this.TestRunStatistics = stats; this.IsCanceled = isCanceled; this.IsAborted = isAborted; this.Error = error; this.AttachmentSets = attachmentSets ?? new Collection <AttachmentSet>(); // Ensuring attachmentSets are not null, so that new attachmentSets can be combined whenever required. this.ElapsedTimeInRunningTests = elapsedTime; }
/// <summary> /// Raise the test run complete event to test loggers and waits /// for the events to be processed. /// </summary> /// <param name="stats">Specifies the stats of the test run.</param> /// <param name="isCanceled">Specifies whether the test run is canceled.</param> /// <param name="isAborted">Specifies whether the test run is aborted.</param> /// <param name="error">Specifies the error that occurs during the test run.</param> /// <param name="attachmentSet">Run level attachment sets</param> /// <param name="elapsedTime">Time elapsed in just running the tests.</param> internal void CompleteTestRun(ITestRunStatistics stats, bool isCanceled, bool isAborted, Exception error, Collection <AttachmentSet> attachmentSet, TimeSpan elapsedTime) { this.CheckDisposed(); var args = new TestRunCompleteEventArgs(stats, isCanceled, isAborted, error, attachmentSet, elapsedTime); // Sending 0 size as this event is not expected to contain any data. this.SafeInvokeAsync(() => this.TestRunComplete, args, 0, "InternalTestLoggerEvents.SendTestRunComplete"); // Wait for the loggers to finish processing the messages for the run. this.loggerEventQueue.Flush(); }
public TestRunStatisticsDrop MapToDrop(ITestRunStatistics testRunStatistics) { return(new TestRunStatisticsDrop { NoneCount = testRunStatistics[TestOutcome.None], PassedCount = testRunStatistics[TestOutcome.Passed], FailedCount = testRunStatistics[TestOutcome.Failed], SkippedCount = testRunStatistics[TestOutcome.Skipped], NotFoundCount = testRunStatistics[TestOutcome.NotFound], ExecutedTestsCount = testRunStatistics.ExecutedTests }); }
public void TestAreDone(ITestRunStatistics stats, bool isCanceled, bool isAborted, Exception error, Collection <Microsoft.VisualStudio.TestPlatform.ObjectModel.AttachmentSet> attachmentSets, TimeSpan elapsedTime) { this.testRunStatistics = stats; this.isCanceled = isCanceled; this.isAborted = isAborted; this.error = error; this.attachmentSets = attachmentSets; this.elapsedTimeInRunningTests = elapsedTime; // All tests are done, so generate the report PnPTestSummary summary = GenerateMDTestReport(); // Add this test run to the other test runs in our XML database UpdateXMLTestResultFile(Path.Combine(GetParameter(PnPTestManager.ParameterMDPath), "PnPTestResultsSummary.xml"), summary); }
public void TestAreDone(ITestRunStatistics stats, bool isCanceled, bool isAborted, Exception error, Collection<Microsoft.VisualStudio.TestPlatform.ObjectModel.AttachmentSet> attachmentSets, TimeSpan elapsedTime) { this.testRunStatistics = stats; this.isCanceled = isCanceled; this.isAborted = isAborted; this.error = error; this.attachmentSets = attachmentSets; this.elapsedTimeInRunningTests = elapsedTime; // All tests are done, so generate the report PnPTestSummary summary = GenerateMDTestReport(); // Add this test run to the other test runs in our XML database UpdateXMLTestResultFile(Path.Combine(GetParameter(PnPTestManager.ParameterMDPath), "PnPTestResultsSummary.xml"), summary); }
/// <summary> /// Aggregate Run Data /// Must be thread-safe as this is expected to be called by parallel managers /// </summary> public void Aggregate( ITestRunStatistics testRunStats, ICollection <string> executorUris, Exception exception, TimeSpan elapsedTime, bool isAborted, bool isCanceled, ICollection <AttachmentSet> runContextAttachments, Collection <AttachmentSet> runCompleteArgsAttachments) { lock (dataUpdateSyncObject) { this.IsAborted = this.IsAborted || isAborted; this.IsCanceled = this.IsCanceled || isCanceled; ElapsedTime = TimeSpan.FromMilliseconds(Math.Max(ElapsedTime.TotalMilliseconds, elapsedTime.TotalMilliseconds)); if (runContextAttachments != null) { foreach (var attachmentSet in runContextAttachments) { RunContextAttachments.Add(attachmentSet); } } if (runCompleteArgsAttachments != null) { RunCompleteArgsAttachments.AddRange(runCompleteArgsAttachments); } if (exception != null) { Exceptions.Add(exception); } if (executorUris != null) { this.executorUris.AddRange(executorUris); } if (testRunStats != null) { testRunStatsList.Add(testRunStats); } } }
/// <summary> /// VSTestLogger method being called when testing is done /// </summary> /// <param name="stats">Test statistocs</param> /// <param name="isCanceled">Was the test cancelled</param> /// <param name="isAborted">Was the test aborted</param> /// <param name="error">Was there an error</param> /// <param name="attachmentSets">Test attachements</param> /// <param name="elapsedTime">How long did the test run</param> public void TestAreDone(ITestRunStatistics stats, bool isCanceled, bool isAborted, Exception error, Collection <Microsoft.VisualStudio.TestPlatform.ObjectModel.AttachmentSet> attachmentSets, TimeSpan elapsedTime) { testRun.TestWasCancelled = isCanceled; testRun.TestWasAborted = isAborted; testRun.TestTime = elapsedTime; testRun.Status = RunStatus.Done; // count tests and store summary in the TestRun row var passedTests = testRun.TestResults.Where(r => r.Outcome == Outcome.Passed).ToList().Count(); var failedTests = testRun.TestResults.Where(r => r.Outcome == Outcome.Failed).ToList().Count(); var skippedTests = testRun.TestResults.Where(r => r.Outcome == Outcome.Skipped).ToList().Count(); var notFoundTests = testRun.TestResults.Where(r => r.Outcome == Outcome.NotFound).ToList().Count(); testRun.TestsPassed = passedTests; testRun.TestsFailed = failedTests; testRun.TestsSkipped = skippedTests; testRun.TestsNotFound = notFoundTests; SaveChanges(); }
public void HandleTestRunComplete( TestRunCompleteEventArgs testRunCompleteArgs, TestRunChangedEventArgs lastChunkArgs, ICollection <AttachmentSet> runContextAttachments, ICollection <string> executorUris) { if (lastChunkArgs?.NewTestResults != null) { TestResults.AddRange(lastChunkArgs.NewTestResults); foreach (var newTestResult in lastChunkArgs.NewTestResults) { TestResultAvailable?.Invoke(this, new VsTestResultEventArgs(newTestResult)); } } if (testRunCompleteArgs != null) { TestRunStatistics = testRunCompleteArgs.TestRunStatistics; } waitHandle.Set(); }
public TestRunStatisticsDrop(ITestRunStatistics testRunStatistics) { _testRunStatistics = testRunStatistics; }
/// <summary> /// Initializes a new instance of the <see cref="TestRunChangedEventArgs"/> class. /// </summary> /// <param name="stats"> The stats. </param> /// <param name="newTestResults"> The new test results. </param> /// <param name="activeTests"> The active tests. </param> public TestRunChangedEventArgs(ITestRunStatistics stats, IEnumerable <TestResult> newTestResults, IEnumerable <TestCase> activeTests) { this.TestRunStatistics = stats; this.NewTestResults = newTestResults; this.ActiveTests = activeTests; }
/// <summary> /// VSTestLogger method being called when testing is done /// </summary> /// <param name="stats">Test statistocs</param> /// <param name="isCanceled">Was the test cancelled</param> /// <param name="isAborted">Was the test aborted</param> /// <param name="error">Was there an error</param> /// <param name="attachmentSets">Test attachements</param> /// <param name="elapsedTime">How long did the test run</param> public void TestAreDone(ITestRunStatistics stats, bool isCanceled, bool isAborted, Exception error, Collection<Microsoft.VisualStudio.TestPlatform.ObjectModel.AttachmentSet> attachmentSets, TimeSpan elapsedTime) { testRun.TestWasCancelled = isCanceled; testRun.TestWasAborted = isAborted; testRun.TestTime = elapsedTime; testRun.Status = RunStatus.Done; // count tests and store summary in the TestRun row var passedTests = testRun.TestResults.Where(r => r.Outcome == Outcome.Passed).ToList().Count(); var failedTests = testRun.TestResults.Where(r => r.Outcome == Outcome.Failed).ToList().Count(); var skippedTests = testRun.TestResults.Where(r => r.Outcome == Outcome.Skipped).ToList().Count(); var notFoundTests = testRun.TestResults.Where(r => r.Outcome == Outcome.NotFound).ToList().Count(); testRun.TestsPassed = passedTests; testRun.TestsFailed = failedTests; testRun.TestsSkipped = skippedTests; testRun.TestsNotFound = notFoundTests; SaveChanges(); }