Consider:
[Test]
public void Test1()
{
Trace.TraceInformation("Hello");
}
When running it from Visual Studio 2015, the output window (Tests) shows no trace lines:
------ Discover test started ------
NUnit Adapter 3.4.0.0: Test discovery starting
NUnit Adapter 3.4.0.0: Test discovery complete
========== Discover test finished: 9 found (0:00:01.325888) ==========
------ Run test started ------
NUnit Adapter 3.4.0.0: Test execution started
Running selected tests in C:\Projects\bla-bla.dll
NUnit3TestExecutor converted 9 of 9 NUnit test cases
NUnit Adapter 3.4.0.0: Test execution complete
========== Run test finished: 1 run (0:00:03.5445181) ==========
I remember it was working fine with NUnit 2 and Visual Studio 2013. Do I need to somehow turn it on?
My app.config
has no overrides to default <system.diagnostics>
.
The NUnit Test Adapter allows you to run NUnit tests inside Visual Studio. The current release, version 2-0, is designed to work with Studio 2012 (All updates), Visual Studio 2013 (All updates) and Visual Studio 2015 (tested with all pre-releases, checked April 2015).
If Test Explorer is not visible, choose Test on the Visual Studio menu, choose Windows, and then choose Test Explorer (or press Ctrl + E, T). As you run, write, and rerun your tests, the Test Explorer displays the results in a default grouping of Project, Namespace, and Class.
According to this discussion, they removed that because of technical reasons.
An alternative solution might be something like this:
using NUnit.Framework;
namespace MyUnitTest {
[TestFixture]
public class UnitTest1 {
[Test()]
public void Test1() {
var x = "Before Test";
TestContext.Progress.WriteLine(x);
x = "Hello";
TestContext.Progress.WriteLine(x);
Assert.IsTrue(x == "Hello");
x = "After Test";
TestContext.Progress.WriteLine(x);
}
}
}
With the given result:
NUnit Adapter 3.4.1.0: Test execution started Running selected tests in C:\ProjectPath\MyUnitTest.dll NUnit3TestExecutor converted 1 of 1
NUnit test cases Before Test Hello After Test NUnit Adapter 3.4.1.0:
Test execution complete
========== Test execution complete: 1 run(0:00:00,7660762) ==========
You can't use Trace
anymore on outputs for NUnit.
Option 1: You can use the output window to review trace information
Option 2: In your startup, add a TextWriterTraceListener
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With