Skip to content

Commit

Permalink
Added processingSettings
Browse files Browse the repository at this point in the history
  • Loading branch information
jakubch1 committed Jul 1, 2020
1 parent 1267291 commit 1aee79f
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -96,11 +96,12 @@ public interface IVsTestConsoleWrapperAsync
/// Provides back all attachments to TestPlatform for additional processing (for example merging)
/// </summary>
/// <param name="attachments">Collection of attachments</param>
/// <param name="multiTestRunCompleted">Indicates that all test executions are done and all data is provided</param>
/// <param name="processingSettings">XML processing settings</param>
/// <param name="isLastBatch">Indicates that all test executions are done and all data is provided</param>
/// <param name="collectMetrics">Enables metrics collection (used for telemetry)</param>
/// <param name="eventsHandler">EventHandler to receive session complete event</param>
/// <param name="cancellationToken">Cancellation token</param>
Task ProcessTestRunAttachmentsAsync(IEnumerable<AttachmentSet> attachments, bool multiTestRunCompleted, bool collectMetrics, ITestRunAttachmentsProcessingEventsHandler eventsHandler, CancellationToken cancellationToken);
Task ProcessTestRunAttachmentsAsync(IEnumerable<AttachmentSet> attachments, string processingSettings, bool isLastBatch, bool collectMetrics, ITestRunAttachmentsProcessingEventsHandler eventsHandler, CancellationToken cancellationToken);

/// <summary>
/// See <see cref="IVsTestConsoleWrapper.EndSession"/>.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -276,7 +276,7 @@ public void EndSession()

#endregion

#region IVsTestConsoleWrapper
#region IVsTestConsoleWrapperAsync

/// <inheritdoc/>
public async Task StartSessionAsync()
Expand Down Expand Up @@ -407,7 +407,7 @@ public async Task RunTestsWithCustomTestHostAsync(IEnumerable<TestCase> testCase
}

/// <inheritdoc/>
public async Task ProcessTestRunAttachmentsAsync(IEnumerable<AttachmentSet> attachments, bool multiTestRunCompleted, bool collectMetrics, ITestRunAttachmentsProcessingEventsHandler testSessionEventsHandler, CancellationToken cancellationToken)
public async Task ProcessTestRunAttachmentsAsync(IEnumerable<AttachmentSet> attachments, string processingSettings, bool isLastBatch, bool collectMetrics, ITestRunAttachmentsProcessingEventsHandler testSessionEventsHandler, CancellationToken cancellationToken)
{
this.testPlatformEventSource.TranslationLayerTestRunAttachmentsProcessingStart();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public async Task TestRunWithCodeCoverageAndAttachmentsProcessing(RunnerInfo run
Assert.AreEqual(2, this.runEventHandler.Attachments.Count);

// act
await this.vstestConsoleWrapper.ProcessTestRunAttachmentsAsync(runEventHandler.Attachments, true, true, testRunAttachmentsProcessingEventHandler, CancellationToken.None);
await this.vstestConsoleWrapper.ProcessTestRunAttachmentsAsync(runEventHandler.Attachments, null, true, true, testRunAttachmentsProcessingEventHandler, CancellationToken.None);

// Assert
testRunAttachmentsProcessingEventHandler.EnsureSuccess();
Expand Down Expand Up @@ -153,7 +153,7 @@ public async Task TestRunWithCodeCoverageAndAttachmentsProcessingNoMetrics(Runne
Assert.AreEqual(2, this.runEventHandler.Attachments.Count);

// act
await this.vstestConsoleWrapper.ProcessTestRunAttachmentsAsync(runEventHandler.Attachments, true, false, testRunAttachmentsProcessingEventHandler, CancellationToken.None);
await this.vstestConsoleWrapper.ProcessTestRunAttachmentsAsync(runEventHandler.Attachments, null, true, false, testRunAttachmentsProcessingEventHandler, CancellationToken.None);

// Assert
testRunAttachmentsProcessingEventHandler.EnsureSuccess();
Expand Down Expand Up @@ -200,7 +200,7 @@ public async Task TestRunWithCodeCoverageAndAttachmentsProcessingModuleDuplicate
Assert.AreEqual(3, this.runEventHandler.Attachments.Count);

// act
await this.vstestConsoleWrapper.ProcessTestRunAttachmentsAsync(runEventHandler.Attachments, true, true, testRunAttachmentsProcessingEventHandler, CancellationToken.None);
await this.vstestConsoleWrapper.ProcessTestRunAttachmentsAsync(runEventHandler.Attachments, null, true, true, testRunAttachmentsProcessingEventHandler, CancellationToken.None);

// Assert
testRunAttachmentsProcessingEventHandler.EnsureSuccess();
Expand Down Expand Up @@ -252,7 +252,7 @@ public async Task TestRunWithCodeCoverageAndAttachmentsProcessingCancelled(Runne

CancellationTokenSource cts = new CancellationTokenSource();

Task attachmentsProcessing = this.vstestConsoleWrapper.ProcessTestRunAttachmentsAsync(attachments, true, true, testRunAttachmentsProcessingEventHandler, cts.Token);
Task attachmentsProcessing = this.vstestConsoleWrapper.ProcessTestRunAttachmentsAsync(attachments, null, true, true, testRunAttachmentsProcessingEventHandler, cts.Token);

while (true)
{
Expand Down Expand Up @@ -318,7 +318,7 @@ public async Task EndSessionShouldEnsureVstestConsoleProcessDies(RunnerInfo runn
Assert.AreEqual(6, this.runEventHandler.TestResults.Count);
Assert.AreEqual(2, this.runEventHandler.Attachments.Count);

await this.vstestConsoleWrapper.ProcessTestRunAttachmentsAsync(runEventHandler.Attachments, true, true, testRunAttachmentsProcessingEventHandler, CancellationToken.None);
await this.vstestConsoleWrapper.ProcessTestRunAttachmentsAsync(runEventHandler.Attachments, null, true, true, testRunAttachmentsProcessingEventHandler, CancellationToken.None);

// act
this.vstestConsoleWrapper?.EndSession();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ public async Task ProcessTestRunAttachmentsAsync_ShouldReturnInitialAttachmentsT
mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny<ICollection<AttachmentSet>>(), It.IsAny<IProgress<int>>(), It.IsAny<IMessageLogger>(), It.IsAny<CancellationToken>()), Times.Never);
mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny<ICollection<AttachmentSet>>(), It.IsAny<IProgress<int>>(), It.IsAny<IMessageLogger>(), It.IsAny<CancellationToken>()), Times.Never);

VerifyMetrics(0, 0);
VerifyMetrics(inputCount: 0, outputCount: 0);
}

[TestMethod]
Expand All @@ -93,7 +93,7 @@ public async Task ProcessTestRunAttachmentsAsync_ShouldReturnNoAttachments_IfNoA
mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny<ICollection<AttachmentSet>>(), It.IsAny<IProgress<int>>(), It.IsAny<IMessageLogger>(), It.IsAny<CancellationToken>()), Times.Never);
mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny<ICollection<AttachmentSet>>(), It.IsAny<IProgress<int>>(), It.IsAny<IMessageLogger>(), It.IsAny<CancellationToken>()), Times.Never);

VerifyMetrics(0, 0);
VerifyMetrics(inputCount: 0, outputCount: 0);
}

[TestMethod]
Expand All @@ -117,7 +117,7 @@ public async Task ProcessTestRunAttachmentsAsync_ShouldReturn1NotProcessedAttach
mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny<ICollection<AttachmentSet>>(), It.IsAny<IProgress<int>>(), It.IsAny<IMessageLogger>(), It.IsAny<CancellationToken>()), Times.Never);
mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny<ICollection<AttachmentSet>>(), It.IsAny<IProgress<int>>(), It.IsAny<IMessageLogger>(), It.IsAny<CancellationToken>()), Times.Never);

VerifyMetrics(1, 1);
VerifyMetrics(inputCount: 1, outputCount: 1);
}

[TestMethod]
Expand All @@ -140,7 +140,7 @@ public async Task ProcessTestRunAttachmentsAsync_ShouldReturn1NotProcessedAttach
mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny<ICollection<AttachmentSet>>(), It.IsAny<IProgress<int>>(), It.IsAny<IMessageLogger>(), It.IsAny<CancellationToken>()), Times.Never);
mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny<ICollection<AttachmentSet>>(), It.IsAny<IProgress<int>>(), It.IsAny<IMessageLogger>(), It.IsAny<CancellationToken>()), Times.Never);

VerifyMetrics(1, 1);
VerifyMetrics(inputCount: 1, outputCount: 1);
}

[TestMethod]
Expand Down Expand Up @@ -171,7 +171,7 @@ public async Task ProcessTestRunAttachmentsAsync_ShouldReturn1ProcessedAttachmen
mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.Is<ICollection<AttachmentSet>>(c => c.Count == 1 && c.Contains(inputAttachments[0])), It.IsAny<IProgress<int>>(), It.IsAny<IMessageLogger>(), cancellationTokenSource.Token));
mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny<ICollection<AttachmentSet>>(), It.IsAny<IProgress<int>>(), It.IsAny<IMessageLogger>(), It.IsAny<CancellationToken>()), Times.Never);

VerifyMetrics(1, 1);
VerifyMetrics(inputCount: 1, outputCount: 1);
}

[TestMethod]
Expand Down Expand Up @@ -203,7 +203,7 @@ public async Task ProcessTestRunAttachmentsAsync_ShouldReturn1ProcessedAttachmen
mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.Is<ICollection<AttachmentSet>>(c => c.Count == 1 && c.Contains(inputAttachments[0])), It.IsAny<IProgress<int>>(), It.IsAny<IMessageLogger>(), cancellationTokenSource.Token));
mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny<ICollection<AttachmentSet>>(), It.IsAny<IProgress<int>>(), It.IsAny<IMessageLogger>(), It.IsAny<CancellationToken>()), Times.Never);

VerifyMetrics(1, 1);
VerifyMetrics(inputCount: 1, outputCount: 1);
}

[TestMethod]
Expand All @@ -229,7 +229,7 @@ public async Task ProcessTestRunAttachmentsAsync_ShouldReturnInitialAttachmentsT
mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.Is<ICollection<AttachmentSet>>(c => c.Count == 1 && c.Contains(inputAttachments[0])), It.IsAny<IProgress<int>>(), It.IsAny<IMessageLogger>(), cancellationTokenSource.Token));
mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny<ICollection<AttachmentSet>>(), It.IsAny<IProgress<int>>(), It.IsAny<IMessageLogger>(), It.IsAny<CancellationToken>()), Times.Never);

VerifyMetrics(1, 1, "Failed");
VerifyMetrics(inputCount: 1, outputCount: 1, status: "Failed");
}

[TestMethod]
Expand All @@ -254,7 +254,7 @@ public async Task ProcessTestRunAttachmentsAsync_ShouldReturnInitialAttachments_
mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.Is<ICollection<AttachmentSet>>(c => c.Count == 1 && c.Contains(inputAttachments[0])), It.IsAny<IProgress<int>>(), It.IsAny<IMessageLogger>(), cancellationTokenSource.Token));
mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny<ICollection<AttachmentSet>>(), It.IsAny<IProgress<int>>(), It.IsAny<IMessageLogger>(), It.IsAny<CancellationToken>()), Times.Never);

VerifyMetrics(1, 1, "Failed");
VerifyMetrics(inputCount: 1, outputCount: 1, status: "Failed");
}

[TestMethod]
Expand All @@ -277,8 +277,8 @@ public async Task ProcessTestRunAttachmentsAsync_ShouldReturnInitialAttachmentsT
mockAttachmentHandler2.Verify(h => h.GetExtensionUris(), Times.Never);
mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny<ICollection<AttachmentSet>>(), It.IsAny<IProgress<int>>(), It.IsAny<IMessageLogger>(), It.IsAny<CancellationToken>()), Times.Never);
mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny<ICollection<AttachmentSet>>(), It.IsAny<IProgress<int>>(), It.IsAny<IMessageLogger>(), It.IsAny<CancellationToken>()), Times.Never);
VerifyMetrics(1, 1, "Canceled");

VerifyMetrics(inputCount: 1, outputCount: 1, status: "Canceled");
}

[TestMethod]
Expand All @@ -302,7 +302,7 @@ public async Task ProcessTestRunAttachmentsAsync_ShouldReturnInitialAttachments_
mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny<ICollection<AttachmentSet>>(), It.IsAny<IProgress<int>>(), It.IsAny<IMessageLogger>(), It.IsAny<CancellationToken>()), Times.Never);
mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny<ICollection<AttachmentSet>>(), It.IsAny<IProgress<int>>(), It.IsAny<IMessageLogger>(), It.IsAny<CancellationToken>()), Times.Never);

VerifyMetrics(1, 1, "Canceled");
VerifyMetrics(inputCount: 1, outputCount: 1, status: "Canceled");
}

[TestMethod]
Expand Down Expand Up @@ -343,7 +343,7 @@ public async Task ProcessTestRunAttachmentsAsync_ShouldReturnProcessedAttachment
mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.Is<ICollection<AttachmentSet>>(c => c.Count == 2 && c.Contains(inputAttachments[0]) && c.Contains(inputAttachments[1])), It.IsAny<IProgress<int>>(), It.IsAny<IMessageLogger>(), cancellationTokenSource.Token));
mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.Is<ICollection<AttachmentSet>>(c => c.Count == 2 && c.Contains(inputAttachments[2]) && c.Contains(inputAttachments[3])), It.IsAny<IProgress<int>>(), It.IsAny<IMessageLogger>(), cancellationTokenSource.Token));

VerifyMetrics(5, 3);
VerifyMetrics(inputCount: 5, outputCount: 3);
}

[TestMethod]
Expand Down Expand Up @@ -385,7 +385,7 @@ public async Task ProcessTestRunAttachmentsAsync_ShouldReturnProcessedAttachment
mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.Is<ICollection<AttachmentSet>>(c => c.Count == 2 && c.Contains(inputAttachments[0]) && c.Contains(inputAttachments[1])), It.IsAny<IProgress<int>>(), It.IsAny<IMessageLogger>(), cancellationTokenSource.Token));
mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.Is<ICollection<AttachmentSet>>(c => c.Count == 2 && c.Contains(inputAttachments[2]) && c.Contains(inputAttachments[3])), It.IsAny<IProgress<int>>(), It.IsAny<IMessageLogger>(), cancellationTokenSource.Token));

VerifyMetrics(5, 3);
VerifyMetrics(inputCount: 5, outputCount: 3);
}

[TestMethod]
Expand Down Expand Up @@ -450,7 +450,7 @@ public async Task ProcessTestRunAttachmentsAsync_ShouldReturnInitialAttachmentsT
mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.Is<ICollection<AttachmentSet>>(c => c.Count == 1 && c.Contains(inputAttachments[0])), It.IsAny<IProgress<int>>(), It.IsAny<IMessageLogger>(), cancellationTokenSource.Token));
mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny<ICollection<AttachmentSet>>(), It.IsAny<IProgress<int>>(), It.IsAny<IMessageLogger>(), It.IsAny<CancellationToken>()), Times.Never);

VerifyMetrics(1, 1, "Canceled");
VerifyMetrics(inputCount: 1, outputCount: 1, status: "Canceled");
}

[TestMethod]
Expand Down Expand Up @@ -510,7 +510,7 @@ public async Task ProcessTestRunAttachmentsAsync_ShouldReturnInitialAttachments_
mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.Is<ICollection<AttachmentSet>>(c => c.Count == 1 && c.Contains(inputAttachments[0])), It.IsAny<IProgress<int>>(), It.IsAny<IMessageLogger>(), cancellationTokenSource.Token));
mockAttachmentHandler2.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny<ICollection<AttachmentSet>>(), It.IsAny<IProgress<int>>(), It.IsAny<IMessageLogger>(), It.IsAny<CancellationToken>()), Times.Never);

VerifyMetrics(1, 1, "Canceled");
VerifyMetrics(inputCount: 1, outputCount: 1, status: "Canceled");
}

[TestMethod]
Expand Down Expand Up @@ -584,7 +584,7 @@ public async Task ProcessTestRunAttachmentsAsync_ShouldReturnProperlySendProgres
mockEventsHandler.Verify(h => h.HandleLogMessage(TestMessageLevel.Informational, "info"));
mockEventsHandler.Verify(h => h.HandleLogMessage(TestMessageLevel.Error, "error"));

VerifyMetrics(2, 2, "Completed");
VerifyMetrics(inputCount: 2, outputCount: 2);
}

private void VerifyMetrics(int inputCount, int outputCount, string status = "Completed")
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -317,6 +317,7 @@ public async Task ProcessTestRunAttachmentsAsyncShouldSucceed()

await this.consoleWrapper.ProcessTestRunAttachmentsAsync(
attachments,
null,
true,
true,
new Mock<ITestRunAttachmentsProcessingEventsHandler>().Object,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,6 +315,7 @@ public async Task ProcessTestRunAttachmentsAsyncShouldSucceed()

await this.consoleWrapper.ProcessTestRunAttachmentsAsync(
attachments,
null,
true,
true,
new Mock<ITestRunAttachmentsProcessingEventsHandler>().Object,
Expand Down

0 comments on commit 1aee79f

Please sign in to comment.