# TeamCity

In this article we will show you how to integrate Telerik JustMock with **TeamCity**.

## Integrating JustMock within TeamCity using Windows Batch Command

Another approach for integrating TelerikJustMock 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](https://www.telerik.com/products/justmock/documentation/integration/windows-batch-command).

Below you will find steps to follow for running JustMock test DLLs in the TeamCity build process:

1. Start by adding new build step with runner type: **Command Line** to your configuration.
   ![Jenkins And Team City Team City 1](https://www.telerik.com/products/justmock/documentation/assets/fff4b8e31af76848c872ad6ac6c71cb4/jenkinsandteamcity_teamcity1.png)

2. Having this, you are now able to configure it to execute test DLLs via the **cmd.exe** as shown in [Windows Batch Command](https://www.telerik.com/products/justmock/documentation/integration/windows-batch-command).

   ![Jenkins And Team City Team City 2](https://www.telerik.com/products/justmock/documentation/assets/f482788e4262b6a5e97df8b73884431a/jenkinsandteamcity_teamcity2.png)

   You will simply need to pass an appropriate test execution command through the **JustMockRunner.exe**, which will configure the rest of the environment automatically.

   For example:

   ```
   "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**.

1. First you will need to create the build step:

   ![Jenkins And Team City Team City 3](https://www.telerik.com/products/justmock/documentation/assets/bde210bd313a800957d90eeb19de98e5/jenkinsandteamcity_teamcity3.png)

2. Configure its parameters:

   ![Jenkins And Team City Team City 4](https://www.telerik.com/products/justmock/documentation/assets/3ac6570bd2224803e9afd2b6685c30f4/jenkinsandteamcity_teamcity4.png)

3. 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:

   **Configuration steps**

   * Open "Build Parameters".
   * Click "Add new parameter".
   * As a kind, select "Environment variable (env.)".
   * One by one, add the following variables:
     `JUSTMOCK_INSTANCE=1`
     `COR_ENABLE_PROFILING=1`
     `COR_PROFILER={B7ABE522-A68F-44F2-925B-81E7488E9EC0}`

   ![Jenkins And Team City Team City Env Variables](https://www.telerik.com/products/justmock/documentation/assets/b0c2dc19cdaebb126be28ea046c5b5e0/jenkinsandteamcity_teamcityenvvariables.png)

## 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](https://www.telerik.com/products/justmock/documentation/integration/code-coverage/codecoverage-tools).

> **Note**
>
> 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** .

1. Configure the MSTest/NUnit build step and add ".NET Coverage tool":
   ![Jenkins And Team City Team City 6](https://www.telerik.com/products/justmock/documentation/assets/a562bead702f1d1b2faec8ddd46c79dc/jenkinsandteamcity_teamcity6.png)

2. Then link the profilers using the "Telerik JustMock Configuration". This is better explained [here](https://www.telerik.com/products/justmock/documentation/integration/code-coverage/codecoverage-tools).
   ![Jenkins And Team City Team City 8](https://www.telerik.com/products/justmock/documentation/assets/37017770487a314dc29367544ba03ea3/jenkinsandteamcity_teamcity8.png)

3. Finally you will need to set *JUSTMOCK_INSTANCE=1* as environment variable in the "Build Parameters" of your project:
   ![Jenkins And Team City Team City 7](https://www.telerik.com/products/justmock/documentation/assets/ad1db3393bdbe5d51ca98b36a4c68296/jenkinsandteamcity_teamcity7.png)

## See Also

* [CodeCoverage Tools](https://www.telerik.com/products/justmock/documentation/integration/code-coverage/codecoverage-tools)

* [Jenkins CI](https://www.telerik.com/products/justmock/documentation/integration/continuous-integration/jenkins-ci)

* [Windows Batch Command](https://www.telerik.com/products/justmock/documentation/integration/windows-batch-command)

* [GitHub Actions](https://www.telerik.com/products/justmock/documentation/integration/continuous-integration/github)

* [GitLab CI/CD](https://www.telerik.com/products/justmock/documentation/integration/continuous-integration/gitlab)
