问题描述
目前我正在尝试使用 NUnit 在 xml 文件中获取测试结果.我使用的以下命令是:
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:
然后在生成的文件TestResult.xml"中,我有测试运行元素
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"
然后是异常的失败:
<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>
这些是InternalTrace"文件中的最后一个日志:
These are the last logs from "InternalTrace" file:
我从nunit-aget.log"得到的:
And what I have from "nunit-aget.log":
项目中安装的包有:NUnit"、NUnit.Console"、NUnit.ConsoleRunner"、NUnit.Runners"、NUnit3TestAdapter"
Installed packages in the project are: "NUnit", "NUnit.Console", "NUnit.ConsoleRunner", "NUnit.Runners", "NUnit3TestAdapter"
提前致谢
推荐答案
nunit-console 当前不适用于运行 .NET Core 程序集.
The nunit-console doesn't currently work for running .NET Core assemblies.
您需要使用 NUnit3TestAdapter,并通过 dotnet test
运行.
You need to use the NUnit3TestAdapter, and run via dotnet test
instead.
请参阅此处的文档,了解详细信息:https://github.com/nunit/docs/wiki/.NET-Core-and-.NET-Standard
See the docs here, for details of that: https://github.com/nunit/docs/wiki/.NET-Core-and-.NET-Standard
目前我正在尝试使用 NUnit 在 xml 文件中获取测试结果.
不幸的是,这还不适用于 .NET Core.但是,有一个 opn 功能请求,您可以在下面的链接中进行跟踪.欢迎提出请求!
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
这篇关于C# - NUnit 控制台测试生成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!