[英]How I can run NUnit from command line and get xml result file?
I have following code in c#: 我在c#中有以下代码:
NUnit.ConsoleRunner.Runner.Main(new string[]
{
System.Reflection.Assembly.GetExecutingAssembly().Location,
"OpenShop.dll",
});
And I want to save result from this test to xml file after test ends. 我想在测试结束后将测试结果保存到xml文件中。 How to solve this problem? 如何解决这个问题呢?
It appears you're using the console runner directly, which if that's the case then by default it will generate an Xml file on each run. 您似乎直接使用控制台运行器,如果是这种情况,那么默认情况下它将在每次运行时生成一个Xml文件。 It writes it to the working directory with the name TestResult.xml
, so if you just want to save the file somewhere you'd just need to do this: 它将其写入名为TestResult.xml
的工作目录,因此如果您只想将文件保存在某处,则只需执行此操作:
// Run the test like you're currently doing
NUnit.ConsoleRunner.Runner.Main(new string[]
{
System.Reflection.Assembly.GetExecutingAssembly().Location,
"OpenShop.dll",
});
// Save the file to match the name of the assembly, and so it is not
// overwritten on each run
File.Copy("TestResult.xml", "OpenShop-TestResult.xml");
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.