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

Show IFrameworkHandle.SendMessage messages from test adapters. #429

Merged
merged 3 commits into from
Feb 2, 2017
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 @@ -115,6 +115,7 @@ private void SetContext()
this.testRunCache,
this.testExecutionContext,
this.testRunEventsHandler);
this.frameworkHandle.TestRunMessage += OnTestRunMessage;

this.executorUrisThatRanTests = new List<string>();
}
Expand Down Expand Up @@ -227,9 +228,8 @@ internal void Abort()
/// </summary>
internal void Cancel()
{
ITestExecutor activeExecutor = this.activeExecutor;
isCancellationRequested = true;
if (activeExecutor != null)
if (this.activeExecutor != null)
{
Task.Run(() => CancelTestRunInternal(this.activeExecutor));
}
Expand All @@ -239,7 +239,7 @@ private void CancelTestRunInternal(ITestExecutor executor)
{
try
{
activeExecutor.Cancel();
executor.Cancel();
}
catch (Exception e)
{
Expand All @@ -261,6 +261,11 @@ private void CancelTestRunInternal(ITestExecutor executor)

#region Private methods

private void OnTestRunMessage(object sender, TestRunMessageEventArgs e)
{
this.testRunEventsHandler.HandleLogMessage(e.Level, e.Message);
}

private TimeSpan RunTestsInternal()
{
long totalTests = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,7 +312,6 @@ public void RunTestsShouldInstrumentAdapterExecutionStop()
[TestMethod]
public void RunTestsShouldReportAWarningIfExecutorUriIsNotDefinedInExtensionAssembly()
{
//System.Diagnostics.Debugger.Launch();
var assemblyLocation = typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location;
var executorUriExtensionMap = new List<Tuple<Uri, string>>
{
Expand Down Expand Up @@ -569,6 +568,26 @@ public void RunTestsShouldNotifyItsImplementersOfAnyExceptionThrownByTheExecutor
Assert.IsTrue(isExceptionThrown.HasValue && isExceptionThrown.Value);
}

[TestMethod]
public void RunTestsShouldReportLogMessagesFromExecutors()
{
var assemblyLocation = typeof(BaseRunTestsTests).GetTypeInfo().Assembly.Location;
var executorUriExtensionMap = new List<Tuple<Uri, string>>
{
new Tuple<Uri, string>(new Uri(BaseRunTestsExecutorUri), assemblyLocation)
};
this.runTestsInstance.GetExecutorUriExtensionMapCallback = (fh, rc) => executorUriExtensionMap;
this.runTestsInstance.InvokeExecutorCallback =
(executor, executorUriTuple, runcontext, frameworkHandle) =>
{
frameworkHandle.SendMessage(TestMessageLevel.Error, "DummyMessage");
};

this.runTestsInstance.RunTests();

this.mockTestRunEventsHandler.Verify(re => re.HandleLogMessage(TestMessageLevel.Error, "DummyMessage"));
}

#endregion

#region Private Methods
Expand Down