使用TeamCity和Fakes框架进行构建和测试 [英] Build and test with TeamCity and Fakes Framework
问题描述
我们正在运行在计算机上安装了VS2013的TeamCity 8.1.4构建服务器.
We are running a TeamCity 8.1.4 buildserver with VS2013 installed on the machine.
我最近介绍了依赖于Microsoft Fakes Framework的测试.因此,我必须对新的Fake程序集和Microsoft.VisualStudio.TestTools.UnitTesting
程序集添加一些引用.
这些都可以在我的本地开发计算机上正常运行.
I've recently introduced tests which rely on the Microsoft Fakes Framework. Because of this I had to add some references to the new Fake assemblies and the Microsoft.VisualStudio.TestTools.UnitTesting
assembly.
This all runs fine on my local development machine.
现在,当我尝试在TeamCity服务器上构建解决方案时,会引发以下错误:
Now, when I try to build the solution on the TeamCity server, the following errors are thrown:
SomeDirectory \ Processors \ ProcessorTests.cs(3,27):错误CS0234: 类型或名称空间名称"Fakes"在名称空间中不存在 "SomeDirectory.Database"(您是否缺少程序集引用?)
SomeDirectory\Processors\ProcessorTests.cs(3, 27): error CS0234: The type or namespace name 'Fakes' does not exist in the namespace 'SomeDirectory.Database' (are you missing an assembly reference?)
SomeDirectory \ Processors \ ProcessorTests.cs(7,66):错误CS0234: 类型或名称空间名称"Fakes"在名称空间中不存在 'SomeDirectory.Service.Processor.Report.Processors'(您丢失了吗? 组装参考?)
SomeDirectory\Processors\ProcessorTests.cs(7, 66): error CS0234: The type or namespace name 'Fakes' does not exist in the namespace 'SomeDirectory.Service.Processor.Report.Processors' (are you missing an assembly reference?)
SomeDirectory \ Processors \ ProcessorTests.cs(9,17):错误CS0234: 类型或名称空间名称'QualityTools'在名称空间中不存在 微软"(您是否缺少程序集引用?)
SomeDirectory\Processors\ProcessorTests.cs(9, 17): error CS0234: The type or namespace name 'QualityTools' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)
我有点理解前两个错误,因为我没有在SVN中提交Fake程序集,因此找不到它们.我也不想提交这些文件,因为构建服务器应自行生成这些文件.伪造文件的BuildAction
设置为Fakes
.
I somewhat understand the first two errors, because I haven't committed the Fake assemblies in SVN, therefore they can't be found. I also don't want to commit these files, because the build server should generate these by itself. The BuildAction
of the fakes-files is set to Fakes
.
我的猜测是,前两个错误的起因是第三个错误.据我所知,QualityTools
名称空间位于Microsoft.VisualStudio.TestTools.UnitTesting
程序集中.
My guess is the first two errors have their origin met at the third error. To my knowledge the QualityTools
namespace resides in the Microsoft.VisualStudio.TestTools.UnitTesting
assembly.
我尝试通过几种设置来解决此问题. 我配置的原始构建步骤是:
I've tried to fix this with several settings. The original build step I had configured was:
流道类型= Visual Studio(sln)
Runner type = Visual Studio (sln)
Visual Studio = Microsoft Visual
Visual Studio = Microsoft Visual
Studio 2013
Studio 2013
我已将其更改为:
Runner类型= MSBuild
Runner type = MSBuild
MSBuild版本= Microsoft Build Tools 2013
MSBuild version = Microsoft Build Tools 2013
MSBuild ToolsVersion = 12.0
MSBuild ToolsVersion = 12.0
我还尝试了使用ToolsVersion 4.0
的MSBuild版本.NET 4.5
.
I've also tried the MSBuild version .NET 4.5
with ToolsVersion 4.0
.
所有这些设置都会导致相同的错误.
All of these settings result in the same errors.
如您所知,该解决方案目前无法编译,因此我无法确定测试是否可以运行.我已经找到 a发布有关如何使用TeamCity配置测试步骤,但这是下一步.
As you can understand, the solution won't compile at the moment, so I can't tell for sure if the tests will run or not. I've already found a post on how to configure the test step with TeamCity, but that's the next step.
有人知道如何使用TeamCity和VS2013解决这些问题吗?
Anyone got an idea on how to fix these issues with TeamCity and VS2013?
修改
我已经检查了文件系统上是否存在TestTools.UnitTesting
程序集.该程序集已经存在,所以这应该没问题
I've already checked if the TestTools.UnitTesting
assembly exists on the filesystem. This assembly is present, so this shouldn't be a problem
编辑2
糟糕,我误读了第三条错误消息.我应该一直在寻找Microsoft.QualityTools.Testing.Fakes
程序集,因为它说它无法解析QualityTools
命名空间.检查路径Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\PublicAssemblies
后,我可以确认文件系统中没有dll.
Oops, I've misread the third error message. I should have been looking for the Microsoft.QualityTools.Testing.Fakes
assembly, because it says it can't resolve the QualityTools
namespace. After checking the path Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\PublicAssemblies
I can confirm the dll isn't present on the filesystem.
我已将其手动复制到构建服务器,然后看接下来会发生什么.
I've copied it manually to the buildserver and see what will happen next.
编辑3
将Microsoft.QualityTools.Testing.Fakes
程序集复制到构建服务器后,该解决方案像一个超级按钮一样进行编译.但是,现在我收到了熟悉的
After having copied the Microsoft.QualityTools.Testing.Fakes
assembly to the build server, the solution compiles like a charm. However, now I'm receiving the familiar
无法从COR_PROFILER_PATH和 COR_PROFILER环境变量.
Failed to resolve profiler path from COR_PROFILER_PATH and COR_PROFILER environment variables.
我以前在TFS2012服务器上看到过这一点.这意味着它无法处理垫片,我们不得不升级到TFS2013.
I've seen this before on a TFS2012 server. This meant it wasn't able to handle shims and we had to upgrade to TFS2013.
我刚刚登录构建服务器,看到VS2013版本已过期.这也许就是它不能正常工作的原因.已安装的VS2012安装版本为11.0.50727.1,因此未安装更新3.我将与同事讨论是否可以更新.希望这能解决我在假货和垫片方面面临的问题.
I just logged in on the buildserver and saw the VS2013 version is expired. That's perhaps the reason it doesn't work properly. The installed VS2012 installation is version 11.0.50727.1, so Update 3 is not installed. I'll discuss with my colleagues if this can be updated. Hopefully this will resolve the issues I'm facing with the fakes and shims.
已解决 显然有人认为在构建服务器上安装VS2013 Professional很有趣.因此,假货无法运行,因为这是高级功能.安装了高级版,现在一切都变得像魅惑一样.
Resolved Apparently someone thought it was funny to install the VS2013 Professional on the buildserver. Therefore the fakes couldn't run, as it's a Premium feature. Installed the Premium version and everything works like a charm now.
推荐答案
伪造的MSTest无法运行,而您必须拥有VSTest.Console
Fakes wont run with MSTest you have to you VSTest.Console
通常(在这种情况下为VS2012)位于C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe
Usually (for VS2012 in this case) it is located C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\CommonExtensions\Microsoft\TestWindow\vstest.console.exe
http://confluence.jetbrains.com/上也有可用的亚军. display/TW/VSTest.Console + Runner ,但是如果不起作用,请手动"运行可执行文件,这里是运行vstest.console.exe
There is also runner available on http://confluence.jetbrains.com/display/TW/VSTest.Console+Runner, but if this doesnt work, run the executable "by hand", here is reference for running vstest.console.exe
http://msdn.microsoft.com/en-us/library/jj155796.aspx.
如果在代理计算机上安装了VS2013(专业版包含伪造品,而Express不包含),则应可以正常编译.您是否在开发机上尝试过干净结帐?
If you have VS2013 installed on agent machine (Pro edition contains fakes, express doesn't) it should compile fine. Have you tried clean checkout on your dev machine?
这篇关于使用TeamCity和Fakes框架进行构建和测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!