的MSBuild运行单元测试 [英] MSBuild to run unit tests

查看:345
本文介绍了的MSBuild运行单元测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想配置CruiseControl的.NET周期性地建设我们的资料库code和运行包含在解决方案中的测试。我已经配置从SVN服务器和建筑部分检索code。但我无法在其上运行的测试。 MSBuild的不断抱怨说。

I am trying to configure CruiseControl .net to build our repository code periodically and run the tests included in the solution. I have configured the retrieving code from the svn server and building part. But I am unable to run tests on it. MSBuild keeps on complaining that.

错误MSB4057:目标测试呢
  在项目中不存在

error MSB4057: The target "Test" does not exist in the project.

我也尝试通过运行命令行测试,看看是否具有相同的错误工作。我用:MSBuild.exe TestProject.csproj /吨:测试

I also tried running the tests through command line to see if that works with the same error. I used: MSBuild.exe TestProject.csproj /t:Test

我的配置是这样的:

<tasks>
    <msbuild>
        <executable>C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe</executable>
        <workingDirectory>C:\WorkingDir\build\MainProject</workingDirectory>                
        <projectFile>MainProject.csproj</projectFile>
        <buildArgs>/noconsolelogger /p:Configuration=Debug /v:diag</buildArgs>
        <targets>Build</targets>
        <timeout>900</timeout>
        <logger>C:\Program Files (x86)\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MSBuild.dll</logger>
    </msbuild>
    <msbuild>
        <executable>C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe</executable>
        <workingDirectory>C:\WorkingDir\build\TestProject</workingDirectory>                
        <projectFile>TestProject.csproj</projectFile>
        <buildArgs>/noconsolelogger /p:Configuration=Debug /v:diag</buildArgs>
        <targets>Test</targets>
        <timeout>900</timeout>
        <logger>C:\Program Files (x86)\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MSBuild.dll</logger>
    </msbuild>  
    </tasks>

我想AP preciate在正确的方向的蛛丝马迹。

I would appreciate any hint in the right direction.

推荐答案

您还没有解释你所使用的测试框架,这是pretty关键在这里。

You havent explained what test framework you're using, which is pretty key here.

有关MSTest的,这个调用东西是TFS [作为亚军的东西部分是Visual Studio中,这就是为什么一个任务运行MSTest的不能MSBuild的,这是.NET Framework的一部分的一部分的一部分 - 这也是为什么MSTest的力量[在2010年的一个子集]要安装Visual Studio您的构建服务器上(也有在这里关于该主题的好几个问题)]

For MSTest, this invocation stuff is part of TFS [as the runner stuff is part of Visual Studio, which is why a Task to run MSTest can not be part of MSBuild, which is part of the .NET Framework -- this is also why MSTest forces [in 2010, a subset of] Visual Studio to be installed on your build server (there are a good few questions around here on that topic)]

对于xUnit.net,人们做这样的东西

有关的NUnit有可以提供文件列表以一个任务。

For NUnit there's a task that you can supply a list of files to.

底线 - 自动加入一个测试自定义目标触发显着的MSBuild包装任务调用测试运行一个文件的.csproj

Bottom line - one adds a Test custom target to a .csproj file which triggers the salient MSBuild wrapper task for invoking your test runner.

这篇关于的MSBuild运行单元测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆