Skip to content

Commit

Permalink
Add support for immediate test output #3.
Browse files Browse the repository at this point in the history
  • Loading branch information
jcansdale committed Oct 3, 2016
1 parent b88ab7d commit 9d387f3
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 6 deletions.
7 changes: 7 additions & 0 deletions src/NUnitTDNet.Adapter.Examples/Expected/TestOutputLines.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ public class TestOutputLines
{
const string ClassName = "NUnitTDNet.Adapter.Examples.Expected.OutputLineTests";

[Test]
[ExpectOutputLine("__TestContext_Progress_WriteLine__")]
public void TestContext_Progress_WriteLine()
{
TestContext.Progress.WriteLine("__TestContext_Progress_WriteLine__");
}

[Test]
[ExpectOutputLine("Hello, World!")]
public void HelloWorld()
Expand Down
20 changes: 14 additions & 6 deletions src/NUnitTDNet.Adapter/EngineTestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,15 @@ public class EngineTestRunner : TDF.ITestRunner
public EngineTestRunner()
{
engine = new TestEngineClass();
engine.Services.Add(new SettingsService(false));
engine.Services.Add(new SettingsService(false)); // Might not be required.
engine.Services.Add(new ExtensionService());

engine.Services.Add(new InProcessTestRunnerFactory());
engine.Services.Add(new DriverService());

engine.Services.Add(new TestFilterService()); // +
engine.Services.Add(new ProjectService()); // +
engine.Services.Add(new RuntimeFrameworkService()); // +
engine.Services.Add(new TestFilterService());
engine.Services.Add(new ProjectService());
engine.Services.Add(new RuntimeFrameworkService());

engine.Services.ServiceManager.StartServices();
}
Expand Down Expand Up @@ -120,7 +120,7 @@ internal int TotalTests
get; private set;
}

public TestEventListener(TDF.ITestListener testListener, /* int totalTests, */ string testRunnerName)
public TestEventListener(TDF.ITestListener testListener, string testRunnerName)
{
this.testListener = testListener;
this.testRunnerName = testRunnerName;
Expand Down Expand Up @@ -157,6 +157,9 @@ public void OnTestEvent(string report)
processOutput(element);
processTest(element, report, false);
break;
case "test-output":
processTestOutput(element);
break;
case "test-run":
// Don't process output.
break;
Expand Down Expand Up @@ -208,7 +211,6 @@ void processTest(XmlElement element, string report, bool isTestCase)
TDF.TestState state;
switch (result)
{
// What about Error?
case "Failed":
state = TDF.TestState.Failed;
TestRunState = TDF.TestRunState.Failure;
Expand Down Expand Up @@ -252,6 +254,12 @@ void processOutput(XmlElement element)
}
}

void processTestOutput(XmlElement element)
{
var text = trimNewLine(element.InnerText);
testListener.WriteLine(text, TDF.Category.Output);
}

static string trimNewLine(string text)
{
var newLine = Environment.NewLine;
Expand Down

0 comments on commit 9d387f3

Please sign in to comment.