Build and test with TeamCity and Fakes Framework

痞子三分冷 提交于 2019-12-13 13:12:28

问题


We are running a TeamCity 8.1.4 buildserver with VS2013 installed on the machine.

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.

Now, when I try to build the solution on the TeamCity server, the following errors are thrown:

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): 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): error CS0234: The type or namespace name 'QualityTools' does not exist in the namespace 'Microsoft' (are you missing an assembly reference?)

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.

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:

Runner type = Visual Studio (sln)

Visual Studio = Microsoft Visual

Studio 2013

I've changed this to:

Runner type = MSBuild

MSBuild version = Microsoft Build Tools 2013

MSBuild ToolsVersion = 12.0

I've also tried the MSBuild version .NET 4.5 with ToolsVersion 4.0.

All of these settings result in the same errors.

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.

Anyone got an idea on how to fix these issues with TeamCity and VS2013?

Edit

I've already checked if the TestTools.UnitTesting assembly exists on the filesystem. This assembly is present, so this shouldn't be a problem

Edit 2

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.

Edit 3

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

Failed to resolve profiler path from COR_PROFILER_PATH and COR_PROFILER environment variables.

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.

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.

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.


回答1:


Fakes wont run with MSTest you have to you VSTest.Console

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

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.

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?



来源:https://stackoverflow.com/questions/25664383/build-and-test-with-teamcity-and-fakes-framework

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!