Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve error logging for VS output #3260

Merged
merged 2 commits into from
Jan 18, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ private async Task<Collection<AttachmentSet>> InternalProcessTestRunAttachmentsA
{
EqtTrace.Error("TestRunAttachmentsProcessingManager: Exception in ProcessTestRunAttachmentsAsync: " + e);

eventHandler?.HandleLogMessage(TestMessageLevel.Error, e.Message);
eventHandler?.HandleLogMessage(TestMessageLevel.Error, e.ToString());
return FinalizeOperation(requestData, new TestRunAttachmentsProcessingCompleteEventArgs(false, e), attachments, stopwatch, eventHandler);
}
}
Expand Down Expand Up @@ -161,7 +161,7 @@ private async Task<Collection<AttachmentSet>> ProcessAttachmentsAsync(string run
catch (Exception e)
{
EqtTrace.Error("TestRunAttachmentsProcessingManager: Exception in ProcessAttachmentsAsync: " + e);
logger.SendMessage(TestMessageLevel.Error, e.Message);
logger.SendMessage(TestMessageLevel.Error, e.ToString());

// Restore the attachment sets for the others attachment processors.
attachments = attachmentsBackup;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,15 +226,16 @@ public async Task ProcessTestRunAttachmentsAsync_ShouldReturnInitialAttachmentsT
new AttachmentSet(new Uri(uri1), "uri1_input")
};

mockAttachmentHandler1.Setup(h => h.ProcessAttachmentSetsAsync(It.IsAny<XmlElement>(), It.IsAny<ICollection<AttachmentSet>>(), It.IsAny<IProgress<int>>(), It.IsAny<IMessageLogger>(), It.IsAny<CancellationToken>())).Throws(new Exception("exception message"));
var exceptionToThrow = new Exception("exception message");
mockAttachmentHandler1.Setup(h => h.ProcessAttachmentSetsAsync(It.IsAny<XmlElement>(), It.IsAny<ICollection<AttachmentSet>>(), It.IsAny<IProgress<int>>(), It.IsAny<IMessageLogger>(), It.IsAny<CancellationToken>())).Throws(exceptionToThrow);

// act
await manager.ProcessTestRunAttachmentsAsync(Constants.EmptyRunSettings, mockRequestData.Object, inputAttachments, new InvokedDataCollector[0], mockEventsHandler.Object, cancellationTokenSource.Token);

// assert
VerifyCompleteEvent(false, false, inputAttachments[0]);
mockEventsHandler.Verify(h => h.HandleTestRunAttachmentsProcessingProgress(It.IsAny<TestRunAttachmentsProcessingProgressEventArgs>()), Times.Never);
mockEventsHandler.Verify(h => h.HandleLogMessage(TestMessageLevel.Error, "exception message"), Times.Once);
mockEventsHandler.Verify(h => h.HandleLogMessage(TestMessageLevel.Error, exceptionToThrow.ToString()), Times.Once);
mockAttachmentHandler1.Verify(h => h.GetExtensionUris());
mockAttachmentHandler2.Verify(h => h.GetExtensionUris(), Times.Once);
mockAttachmentHandler1.Verify(h => h.ProcessAttachmentSetsAsync(It.IsAny<XmlElement>(), It.Is<ICollection<AttachmentSet>>(c => c.Count == 1 && c.Contains(inputAttachments[0])), It.IsAny<IProgress<int>>(), It.IsAny<IMessageLogger>(), cancellationTokenSource.Token));
Expand Down