How can I enable trace output in NUnit 3's Visual Studio adapter?
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) ==========
Conclusion
You can't use Trace
anymore on outputs for NUnit.