简体   繁体   English

在构建上自动运行单元测试

[英]Automatic running of unit tests on build

I would love to know if there is a way I can get Visual Studio to run unit tests corresponding to a given assembly whenever I build it. 我很想知道是否有一种方法可以让Visual Studio在构建时运行与给定程序集相对应的单元测试。

Given a solution containing projects structured like this: 给出包含如下结构的项目的解决方案:

Assembly1

Assembly1.Tests 

Assembly2 

Assembly2.Tests

Is there a way I can get the unit tests in Assembly2.Tests to run whenever Assembly2 is built? 有没有一种方法我可以在单元测试Assembly2.Tests每当运行Assembly2建?

That would be amazing. 这将是惊人的。

I'm using Visual Studio 2008 Standard Edition. 我正在使用Visual Studio 2008标准版。

You can use the nUnit console utility to run the tests as a post-build event for the individual project. 您可以使用nUnit控制台实用程序将测试作为单个项目的生成后事件运行。

You call the nunit-console.exe and supply your assembly containing your tests as an argument. 您调用nunit-console.exe并将包含测试的程序集作为参数提供。

"C:\\Program Files\\NUnit 2.5.7\\bin\\net-2.0\\nunit-console.exe" "PathToTestAssembly.dll" “C:\\ Program Files \\ NUnit 2.5.7 \\ bin \\ net-2.0 \\ nunit-console.exe”“PathToTestAssembly.dll”

or 要么

You can run the tests in the GUI: 您可以在GUI中运行测试:

"C:\\Program Files\\NUnit 2.5.7\\bin\\net-2.0\\nunit.exe" "PathToTestAssembly.dll" /run “C:\\ Program Files \\ NUnit 2.5.7 \\ bin \\ net-2.0 \\ nunit.exe”“PathToTestAssembly.dll”/ run

Edit: 编辑:

Removed the part about the post-build event for the test assembly project. 删除了有关测试装配项目的构建后事件的部分。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM