Reputation: 2047
I have some unit tests which can take several time to complete the execution.
In these I added some messages to show the unit test progress, using Console.WriteLine
.
In my pipeline, during the "Visual Studio Test" task these messages aren't shown. I'd like to see them during the test execution, through the details log view.
Is there any way to achieve this result?
Upvotes: 3
Views: 1439
Reputation: 8725
Create a file named xunit.runner.json
in the top directory of your test project. Content:
{
"diagnosticMessages": true,
"shadowCopy": false
}
I don't known whether shadowCopy
is relevant or why it's there, but the relevant bit is setting diagnosticMessages
to true
.
Then, everything you pass to ITestOutputHelper.WriteLine(...)
will show up in the azure devops pipeline job output in real-time.
This solution currently has the disadvantage that all output shows up as "Warnings" in the visual studio test explorer when run locally, which is distracting and about which I have asked another question here
Upvotes: 0
Reputation: 31083
I'm afraid it's not possible for the console logs. If you use the Visual Studio Test task to run tests, diagnostic output logged from tests (using any of Console.WriteLine, Trace.WriteLine or TestContext.WriteLine methods), will appear as an attachment for a failed test.
However, a full test run output is available in the trx
file found in the test run. If you open the trx
file from the Notepad, you will see there is an Output
element for each test:
<UnitTestResult executionId="xxx" testId="xxx" testName="M2Test" computerName="xxxx" duration="00:00:00.0001844" startTime="2021-01-14T08:10:11.5942741+00:00" endTime="2021-01-14T08:10:11.5962978+00:00" testType="13cdc9d9-xxxx" outcome="Passed" testListId="8cxxxx" relativeResultsDirectory="504xxxxx">
<Output>
<StdOut>cecehi</StdOut>
</Output>
</UnitTestResult>
Upvotes: 2