问题
Currently I am trying to get test results in xml file, using NUnit. The following command that I am using is:
nunit3-console.exe --labels=All --out=TestResult.txt "--result=TestResult.xml;format=nunit3" "Acceptance Tests\AcceptanceTests.dll" --trace:Debug
What I receive in the output window is:
Then inside generated file "TestResult.xml", test-run element I have
testcasecount="1" result="Failed" label="Error" total="1" passed="0" failed="1" inconclusive="0" skipped="0" asserts="0" engine-version="3.7.0.0" clr-version="4.0.30319.42000"
and then is coming failure with the exception:
<failure>
<message><![CDATA[An exception occurred in the driver while loading tests.]]></message>
<stack-trace><![CDATA[
Server stack trace:
at NUnit.Engine.Runners.DirectTestRunner.LoadDriver(IFrameworkDriver driver, String testFile, TestPackage subPackage)
at NUnit.Engine.Runners.DirectTestRunner.LoadPackage()
at NUnit.Engine.Runners.DirectTestRunner.EnsurePackageIsLoaded()
at NUnit.Engine.Runners.DirectTestRunner.RunTests(ITestEventListener listener, TestFilter filter)
at System.Runtime.Remoting.Messaging.StackBuilderSink._PrivateProcessMessage(IntPtr md, Object[] args, Object server, Object[]& outArgs)
at System.Runtime.Remoting.Messaging.StackBuilderSink.SyncProcessMessage(IMessage msg)
Exception rethrown at [0]:
at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg)
at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type)
at NUnit.Engine.ITestEngineRunner.Run(ITestEventListener listener, TestFilter filter)
at NUnit.Engine.Runners.ProcessRunner.RunTests(ITestEventListener listener, TestFilter filter)]]></stack-trace>
</failure>
These are the last logs from "InternalTrace" file:
And what I have from "nunit-aget.log":
Installed packages in the project are: "NUnit", "NUnit.Console", "NUnit.ConsoleRunner", "NUnit.Runners", "NUnit3TestAdapter"
Thanks in advance
回答1:
The nunit-console doesn't currently work for running .NET Core assemblies.
You need to use the NUnit3TestAdapter, and run via dotnet test
instead.
See the docs here, for details of that: https://github.com/nunit/docs/wiki/.NET-Core-and-.NET-Standard
Currently I am trying to get test results in xml file, using NUnit.
Unfortunately, this isn't yet available for .NET Core. There's an opn feature request however, that you can track at the link below. Pull Requests would be welcome!
https://github.com/nunit/nunit3-vs-adapter/issues/323
来源:https://stackoverflow.com/questions/46051922/c-sharp-nunit-console-test-generation