In this article we will show you how to integrate Telerik JustMock with TeamCity.
Integrating JustMock within TeamCity using MS Build Tasks
The first possible way to integrate Telerik JustMock with TeamCity is by using JustMock MSBuild Tasks. This could be appropriate if you have predefined XML for your build process to follow.
Integrating JustMock within TeamCity using Windows Batch Command
Another approach for integrating Telerik JustMock with TeamCity is provided by the "Command Line" runner type build step in the project build configuration. To see how to execute JustMock test DLLs via the Command Prompt, refer to Windows Batch Command.
Below you will find steps to follow for running JustMock test DLLs in the TeamCity build process:
Start by adding new build step with runner type: Command Line to your configuration.
Having this, you are now able to configure it to execute test DLLs via the cmd.exe as shown in Windows Batch Command.
You will simply need to pass an appropriate test execution command through the JustMockRunner.exe, which will configure the rest of the environment automatically.
"C:\Program Files (x86)\Telerik\JustMock\Libraries\JustMockRunner.exe" "C:\Program Files (x86)\Microsoft Visual Studio 11.0\Common7\IDE\MSTest.exe" /testcontainer:"C:\Program Files (x86)\Telerik\JustMock\Examples\Telerik.JustMock.Tests\bin\Debug\Telerik.JustMock.Tests.dll"
Integrating JustMock within TeamCity using MS Test or NUnit build steps
It is also possible to achieve execution of JustMock tests with the MSTest/NUnit build step that comes from TeamCity.
First you will need to create the build step:
Configure its parameters:
The only difference is that, to run elevated tests with JustMock, you will need to have its profiler enabled for the build process. This can be achieved, by setting the JustMock environment variables as build parameters:
Open "Build Parameters".
Click "Add new parameter".
As a kind, select "Environment variable (env.)".
One by one, add the following variables:
Integrating JustMock within TeamCity using MS Test or NUnit build steps with dotCover
If you want to apply code coverage inside MSTest/NUnit build step, you will need to link the profilers first, as shown here.
If you are using the dotCover shipped with TeamCity, you will need to create a build project and run it, to see the dotCover option in JustMock Configuration.
Configure the MSTest/NUnit build step and add ".NET Coverage tool":
Then link the profilers using the "Telerik JustMock Configuration". This is better explained here.
Finally you will need to set JUSTMOCK_INSTANCE=1 as environment variable in the "Build Parameters" of your project: