Skip to content

Commit

Permalink
Show IFrameworkHandle.SendMessage messages from test adapters. (#429)
Browse files Browse the repository at this point in the history
  • Loading branch information
codito authored and Faizan2304 committed Feb 2, 2017
1 parent 5daf25c commit 79b3982
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 4 deletions.
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

0 comments on commit 79b3982

Please sign in to comment.