xUnit.net allows you to capture the output of your tests by using ITestOutputHelper.
In Visual Studio's Test Explorer, The captured output can be viewed by selecting the test case.
On the other hand, if you run a test with the dotnet command, the captured output is not displayed anywhere, which is a bit of a problem if you want the output to be displayed when you run it in CI.
Solution
Use the verbosity=detailed option for the logger to display the output in the console while using the dotnet command.
dotnet test ./tests/MyApp.Tests --logger:"console;verbosity=detailed"
Now you can see the captured output in the console.
√ MyApp.Tests.TestCases.Test1 [4ms]
Standard Output Messages:
Hello from Test
Top comments (0)