简体   繁体   English

如何从命令行运行NUnit并获取xml结果文件?

[英]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.

相关问题 我可以从命令行按顺序运行多个nunit测试吗?(使用nunit控制台运行程序) - Can I run multiple nunit tests sequentially from command line?(using nunit console runner) 如何从命令行从nunit-console运行nunit 2测试? - How do I run nunit 2 tests from nunit-console from the command line? 如何使用NUnit 2.6从命令行运行代码覆盖 - How to run code-coverage from the command line with NUnit 2.6 如何从命令行并行运行 NUnit 测试? - How to run NUnit tests in parallel from command line? 如何编码我的 Nunit 测试以从命令行运行? - How do I code my Nunit tests to run from command line? 从命令行在Ubuntu上运行NUnit测试 - Run NUnit test on Ubuntu from command line 如何使用 NUnit 根据来自外部文件的值在运行时动态运行测试方法? - How can I run test methods dynamically on runtime based on values from external file with NUnit? 如何从Mono的命令行运行SpecFlow? - How can I run SpecFlow from the command line on Mono? 如何在nunit-results.exe生成的html报告中显示nunit结果xml文件中的单个测试名称 - how to display indiviudal test names from a nunit result xml file in the nunit-results.exe generated html report 我在使用Visual Studio和硒进行测试时如何获得NUnit测试结果报告? - How can I get NUnit Testing Result Reports as I am using visual studio and selenium for testing?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM