Skip to content

Commit

Permalink
Fixes #60: Diagnostic messages do not include banner/time
Browse files Browse the repository at this point in the history
  • Loading branch information
bradwilson committed May 3, 2015
1 parent 50486ec commit d47d97f
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System;
using System.Diagnostics;
using Microsoft.VisualStudio.TestPlatform.ObjectModel.Logging;
using Xunit.Abstractions;

Expand All @@ -9,18 +10,20 @@ public class DiagnosticMessageVisitor : TestMessageVisitor
readonly string assemblyDisplayName;
readonly IMessageLogger logger;
readonly bool showDiagnostics;
readonly Stopwatch stopwatch;

public DiagnosticMessageVisitor(IMessageLogger logger, string assemblyDisplayName, bool showDiagnostics)
public DiagnosticMessageVisitor(IMessageLogger logger, string assemblyDisplayName, bool showDiagnostics, Stopwatch stopwatch)
{
this.logger = logger;
this.assemblyDisplayName = assemblyDisplayName;
this.showDiagnostics = showDiagnostics;
this.stopwatch = stopwatch;
}

protected override bool Visit(IDiagnosticMessage diagnosticMessage)
{
if (showDiagnostics)
logger.SendMessage(TestMessageLevel.Warning, String.Format("{0}: {1}", assemblyDisplayName, diagnosticMessage.Message));
logger.SendMessage(TestMessageLevel.Warning, String.Format("[xUnit.net {0}] {1}: {2}", stopwatch.Elapsed, assemblyDisplayName, diagnosticMessage.Message));

return base.Visit(diagnosticMessage);
}
Expand Down
4 changes: 2 additions & 2 deletions xunit.runner.visualstudio.testadapter/VsTestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ void DiscoverTests<TVisitor>(IEnumerable<string> sources,
}
else
{
var diagnosticMessageVisitor = new DiagnosticMessageVisitor(logger, fileName, configuration.DiagnosticMessagesOrDefault);
var diagnosticMessageVisitor = new DiagnosticMessageVisitor(logger, fileName, configuration.DiagnosticMessagesOrDefault, stopwatch);

using (var framework = new XunitFrontController(assemblyFileName, configFileName: null, shadowCopy: true, diagnosticMessageSink: diagnosticMessageVisitor))
{
Expand Down Expand Up @@ -313,7 +313,7 @@ void RunTestsInAssembly(IFrameworkHandle frameworkHandle,
assemblyFileName = Path.Combine(Windows.ApplicationModel.Package.Current.InstalledLocation.Path, Path.GetFileName(assemblyFileName));
#endif

var diagnosticMessageVisitor = new DiagnosticMessageVisitor(frameworkHandle, assemblyDisplayName, runInfo.Configuration.DiagnosticMessagesOrDefault);
var diagnosticMessageVisitor = new DiagnosticMessageVisitor(frameworkHandle, assemblyDisplayName, runInfo.Configuration.DiagnosticMessagesOrDefault, stopwatch);
var controller = new XunitFrontController(assemblyFileName, configFileName: null, shadowCopy: true, diagnosticMessageSink: diagnosticMessageVisitor);

lock (toDispose)
Expand Down

0 comments on commit d47d97f

Please sign in to comment.