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

Dav*_*vid 22 .net build-automation nunit unit-testing visual-studio

我很想知道是否有一种方法可以让Visual Studio在构建时运行与给定程序集相对应的单元测试.

给出包含如下结构的项目的解决方案:

Assembly1

Assembly1.Tests 

Assembly2 

Assembly2.Tests
Run Code Online (Sandbox Code Playgroud)

有没有办法让我可以在Assembly2.Tests建立时运行单元测试Assembly2

这将是惊人的.

我正在使用Visual Studio 2008标准版.

fle*_*her 18

您可以使用nUnit控制台实用程序将测试作为单个项目的生成后事件运行.

您调用nunit-console.exe并将包含测试的程序集作为参数提供.

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

要么

您可以在GUI中运行测试:

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

编辑:

删除了有关测试装配项目的构建后事件的部分.