且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在TFS构建服务器中使用模板运行NUnit测试

更新时间:2021-10-23 23:15:08

帖子•

The post •https://tfsbuildextensions.codeplex.com/wikipage?title=How%20to%20integrate%20the%20nUnit%20build%20activity gives all the steps required to make use of this community TFS extensions. It is meant to be a step by step to get the activity working

注释的第1步显示了如何查找所有已构建的程序集,基本上是扫描a来查找任何以* .dll结尾的文件.我认为这是您提出问题的关键,您只需传递构建生成的所有DLL的列表,然后让nUnit查找测试.如果您想做其他事情,则可以按任何方式构建DLL列表,但是扫描似乎是最简单的,您不必担心自己管理列表

Step 1 of the notes shows how to find all the assemblies that have been built, basically scan a for any file ending *.dll. I think this is the key to your question, you just pass a list of all DLLs produced by the build and let nUnit find the tests. If you want to do something else you can build the list of DLLs any way you want, but a scan seems the most simple, you don't have to worry over managing the list ypourself

第2a步运行nUnit测试,将DLL列表传递到nUnit活动中(实际上是命令行测试运行程序).这将在每个DLL中查找nUnit属性并运行找到的测试.

Step 2a runs the nUnit test, the list of DLLs is passed into the nUnit activity (in effect the command line test runner). This will look in each DLL for the nUnit attributes and run the tests it finds.

步骤2b将结果发布回TFS.这是通过获取测试运行程序的XML输出并将其与MSTEST一起发布到TFS服务器来完成的.

Step 2b publishes the results back to TFS. This is done by taking the XML output of the test runer and publishing it with MSTEST to the TFS server.

如果您使用的是TFS 2012或更高版本,则我不会使用此活动,而是使用TFS中内置的新测试适配器模型 http: //blogs.blackmarble.co.uk/blogs/rfennell/post/2012/03/27/Unit-testing-in-VS11Beta-and-getting-yours-tests-run-on-the-new-TFSPreview- build-service.aspx http://visualstudiogallery. msdn.microsoft.com/c8164c71-0836-4471-80ce-633383031099/

If you are using TFS 2012 or later I would not use this activity, I would use the new test adaptor model built into TFS http://blogs.blackmarble.co.uk/blogs/rfennell/post/2012/03/27/Unit-testing-in-VS11Beta-and-getting-your-tests-to-run-on-the-new-TFSPreview-build-service.aspx and http://visualstudiogallery.msdn.microsoft.com/c8164c71-0836-4471-80ce-633383031099/