MSBuild运行单元测试

编程入门 行业动态 更新时间:2024-10-23 11:29:06
本文介绍了MSBuild运行单元测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我试图配置CruiseControl 定期构建我们的代码库代码,并运行解决方案中包含的测试。我已经配置从svn服务器和构建部分的检索代码。但我无法对其运行测试。 MSBuild不断抱怨。

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

我也试过通过命令行运行测试,看看是否有同样的错误。我使用:MSBuild.exe TestProject.csproj / t:Test

我的配置是这样:

< tasks> < msbuild> <可执行文件> C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe< / executable> < workingDirectory> C:\ WorkingingDir\build\MainProject< / workingDirectory> < projectFile> MainProject.csproj< / projectFile> < buildArgs> / noconsolelogger / p:Configuration = Debug / v:diag< / buildArgs> < targets> Build< / target> < timeout> 900< / timeout> < logger> C:\Program文件(x86)\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MSBuild.dll< / logger> < / msbuild> < msbuild> <可执行文件> C:\WINDOWS\Microsoft.NET\Framework\v4.0.30319\MSBuild.exe< / executable> < workingDirectory> C:\ WorkingingDir\build\TestProject< / workingDirectory> < projectFile> TestProject.csproj< / projectFile> < buildArgs> / noconsolelogger / p:Configuration = Debug / v:diag< / buildArgs> < targets>测试< / targets> < timeout> 900< / timeout> < logger> C:\Program文件(x86)\CruiseControl.NET\server\ThoughtWorks.CruiseControl.MSBuild.dll< / logger> < / msbuild> < / tasks>

我会感谢任何正确方向的提示。

对于MSTest,这是一个非常重要的测试框架,调用的东西是 TFS的一部分 [因为runner的东西是Visual Studio的一部分,这就是为什么运行MSTest的任务不能成为MSBuild的一部分,这是.NET Framework的一部分 - 这也是为什么MSTest强制要在您的构建服务器上安装Visual Studio(在2010年,子集)是这个话题的好几个问题)]

对于xUnit,人们会这样做

对于NUnit,有一个任务,你可以提供一个文件列表。

底线 - 一个测试自定义目标添加到.csproj文件触发显着的MSBuild用于调用测试运行器的包装程序任务。

I am trying to configure CruiseControl 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.

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

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

My configuration is something like this:

<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>

I would appreciate any hint in the right direction.

解决方案

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

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)]

For xUnit, people do stuff like this

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

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运行单元测试

本文发布于:2023-10-31 04:13:12,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1544968.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:单元测试   MSBuild

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!