Is test result file creation now supported by NUnit using dotnet test?
Hi,
The docs for NUnit > .NET Core and .NET Standard indicate that NUnit cannot produce the TestResults.xml file using dotnet test; however, I've been able generate the result file using the package referenced in Add support for producing XML test results. Additionally, the issue mentioned by @SidShetye appears to be resolved, as far as I can tell.
Is test result file creation now supported by NUnit using dotnet test?
If so, can the docs be updated to reflect this? Also, would it be possible to add the NUnitXml.TestLogger package reference automatically, like the other NUnit packages are added when you run dotnet new nunit (mentioned here)?
I'd be happy to update the docs or do anything else needed. Please confirm.
Hi @richardrflores, thanks for raising this.
Is test result file creation now supported by NUnit using dotnet test?
I'm going to tag in @rprouse and @OsirisTerje to ensure I have the correct answer here. Does doing this today require the additional NUnitXml.TestLogger package, or can it be done from the command line with the appropriate arguments?
If so, can the docs be updated to reflect this?
Happy to update the results with the output of this conversation. 👍
would it be possible to add the
NUnitXml.TestLoggerpackage reference automatically, like the other NUnit packages are added when you rundotnet new nunit
That is likely a question for the NUnit project itself (this is just the docs). However, my personal gut feeling would be that NUnit couldn't take a dependency on a 3rd-party package that it doesn't maintain. We could certainly update the docs to suggest adding it afterward, though, if it's indeed the correct way to proceed.
I didn't even realize that issue had been closed or that someone had created a 3rd party logging extension that provided a workaround. I think documenting it would be great!
@richardrflores Sorry for being late in here. Yes, the Nunit3TestAdapter can produce a NUnit3 XML output. It calls the NUnit engine and produce the same report as you would have with the nunit3-console.
This was added in version 3.12 (released Dec 18, 2018).
You enable it by using a NUnit runsettinsg property, TestOutputXml which contains the folder where you want the report written to.
You run it by adding the setting on the command line ( or in a runsettings file ofc):
dotnet test -- NUnit.TestOutputXml=whatever
where whatever is the name of the folder (and as such under the bin/debug/netcore3.1 folder).
Running it on an arbitrary issue like Issue918 produce a result like this:
<?xml version="1.0" encoding="utf-8" standalone="no"?>
<test-run id="0" name="Issue918.dll" fullname="d:\repos\NUnit\nunit3-vs-adapter.issues\Issue918\bin\Debug\netcoreapp3.1\Issue918.dll" runstate="Runnable" testcasecount="1" result="Passed" total="1" passed="1" failed="0" warnings="0" inconclusive="0" skipped="0" asserts="1" engine-version="3.13.0.0" clr-version="3.1.22" start-time="2021-12-19 19:50:28Z" end-time="2021-12-19 19:50:28Z" duration="0.067220">
<command-line><![CDATA[d:\repos\NUnit\nunit3-vs-adapter.issues\Issue918\bin\Debug\netcoreapp3.1\testhost.dll --port 64964 --endpoint 127.0.0.1:064964 --role client --parentprocessid 79876 --telemetryoptedin false]]></command-line>
<test-suite type="Assembly" id="0-1004" name="Issue918.dll" fullname="d:/repos/NUnit/nunit3-vs-adapter.issues/Issue918/bin/Debug/netcoreapp3.1/Issue918.dll" runstate="Runnable" testcasecount="1" result="Passed" start-time="2021-12-19T19:50:28.7322800Z" end-time="2021-12-19T19:50:28.7723347Z" duration="0.040014" total="1" passed="1" failed="0" warnings="0" inconclusive="0" skipped="0" asserts="1">
<environment framework-version="3.13.2.0" clr-version="3.1.22" os-version="Microsoft Windows 10.0.19042" platform="Win32NT" cwd="d:\repos\NUnit\nunit3-vs-adapter.issues\Issue918\bin\Debug\netcoreapp3.1" machine-name="DESKTOP-SIATMVB" user="TerjeSandstrom" user-domain="AzureAD" culture="en-US" uiculture="en-US" os-architecture="x64" />
<settings>
<setting name="SynchronousEvents" value="False" />
<setting name="RandomSeed" value="738862399" />
<setting name="SkipNonTestAssemblies" value="True" />
<setting name="ProcessModel" value="InProcess" />
<setting name="DomainUsage" value="Single" />
<setting name="DefaultTestNamePattern" value="{m}{a}" />
<setting name="WorkDirectory" value="d:\repos\NUnit\nunit3-vs-adapter.issues\Issue918\bin\Debug\netcoreapp3.1" />
<setting name="NumberOfTestWorkers" value="28" />
</settings>
<properties>
<property name="_PID" value="50028" />
<property name="_APPDOMAIN" value="testhost" />
</properties>
<test-suite type="TestSuite" id="0-1005" name="Issue918" fullname="Issue918" runstate="Runnable" testcasecount="1" result="Passed" start-time="2021-12-19T19:50:28.7371493Z" end-time="2021-12-19T19:50:28.7723294Z" duration="0.035176" total="1" passed="1" failed="0" warnings="0" inconclusive="0" skipped="0" asserts="1">
<test-suite type="GenericFixture" id="0-1003" name="Tests+SomeTest<T>" fullname="Issue918.Tests+SomeTest<T>" runstate="Runnable" testcasecount="1" result="Passed" start-time="2021-12-19T19:50:28.7374396Z" end-time="2021-12-19T19:50:28.7723235Z" duration="0.034883" total="1" passed="1" failed="0" warnings="0" inconclusive="0" skipped="0" asserts="1">
<test-suite type="GenericFixture" id="0-1000" name="Tests+SomeTest<T>" fullname="Issue918.Tests+SomeTest<T>" runstate="Runnable" testcasecount="1" result="Passed" start-time="2021-12-19T19:50:28.7374597Z" end-time="2021-12-19T19:50:28.7723086Z" duration="0.034850" total="1" passed="1" failed="0" warnings="0" inconclusive="0" skipped="0" asserts="1">
<test-suite type="TestFixture" id="0-1001" name="Tests+SomeTest<Object>" fullname="Issue918.Tests+SomeTest<Object>" classname="Issue918.Tests+SomeTest`1" runstate="Runnable" testcasecount="1" result="Passed" start-time="2021-12-19T19:50:28.7385249Z" end-time="2021-12-19T19:50:28.7719017Z" duration="0.033380" total="1" passed="1" failed="0" warnings="0" inconclusive="0" skipped="0" asserts="1">
<test-case id="0-1002" name="Foo" fullname="Issue918.Tests+SomeTest<Object>.Foo" methodname="Foo" classname="Issue918.Tests+SomeTest`1" runstate="Runnable" seed="1963098044" result="Passed" start-time="2021-12-19T19:50:28.7404401Z" end-time="2021-12-19T19:50:28.7692699Z" duration="0.028914" asserts="1" />
</test-suite>
</test-suite>
</test-suite>
</test-suite>
</test-suite>
</test-run>
@rprouse @SeanKilleen We really need to get the documentation improved, this is just one more. One thing is that the docs are outdated, another is that we need it to be on a user-based need, meaning around what the user wants to do.