Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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 @@ -218,7 +218,7 @@ public void RunTests()
{
EqtTrace.Error("BaseRunTests.RunTests: Failed to run the tests. Reason: {0}.", ex);

exception = new Exception(ex.Message, ex.InnerException);
Comment thread
nohwnd marked this conversation as resolved.
exception = new Exception(ex.Message, ex);
isAborted = true;
}
finally
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,37 @@ public void RunTestsShouldRaiseTestRunCompleteWithAbortedAsTrueOnException()
Assert.IsTrue(receivedCompleteArgs.IsAborted);
}

[TestMethod]
public void RunTestsShouldPreserveOriginalExceptionAsInnerException()
{
TestRunCompleteEventArgs? receivedCompleteArgs = null;
var originalException = new NotImplementedException("original message");

// Setup mocks.
_runTestsInstance.GetExecutorUriExtensionMapCallback = (fh, rc) => throw originalException;
_mockTestRunEventsHandler.Setup(
treh =>
treh.HandleTestRunComplete(
It.IsAny<TestRunCompleteEventArgs>(),
It.IsAny<TestRunChangedEventArgs>(),
It.IsAny<ICollection<AttachmentSet>>(),
It.IsAny<ICollection<string>>()))
.Callback(
(
TestRunCompleteEventArgs complete,
TestRunChangedEventArgs stats,
ICollection<AttachmentSet> attachments,
ICollection<string> executorUris) => receivedCompleteArgs = complete);

_runTestsInstance.RunTests();

Assert.IsNotNull(receivedCompleteArgs);
Assert.IsTrue(receivedCompleteArgs.IsAborted);
Assert.IsNotNull(receivedCompleteArgs.Error);
Assert.AreSame(originalException, receivedCompleteArgs.Error!.InnerException,
"The original exception should be preserved as the inner exception of the wrapper.");
}

[TestMethod]
public void RunTestsShouldNotThrowIfExceptionIsAFileNotFoundException()
{
Expand Down
Loading