In this article we will learn how we can run MStests in Teamcity for a visual studio solution that is shared online with Git.
What so we need: TeamCity agent on which we can run our tests.
Version Control Settings
Open TeamCity site and go to Administration.
Select the project for which you want to define a new configuration and press the button Create build configuration.
Enter the name and the description and press Create.
Then, we have to attach or create new Version Control Settings for this configuration, used in order to take the latest data for this configuration by using a Version Control system. There are different VC systems like TFS, SVC, etc. In this case we will use GIT.
Press Create and in Type of VCS, select GIT. Then, do the settings like images below (enter name, url, authentication method = password, username and password). Test connection and Create VCS.
Press Create and in Type of VCS, select GIT. Then, do the settings like images below
Build Steps Configuration
Once we have defined a VCS we can start defining the build steps. We need 3 steps, one to restore the packages that are used in the solution, one to build the solution and the last to run the tests.
Step NuGet will look for Nuget.Config and will copy the packages in the location specified in this file.
Nuget.config example:
<?xml version="1.0"
encoding="utf-8"?>
<configuration>
<solution>
<add key="disableSourceControlIntegration"
value="true" />
</solution>
<config>
<add key="repositoryPath" value=".\Packages"
/>
</config>
<packageRestore>
<add key="enabled" value="True" />
<add key="automatic" value="True" />
</packageRestore>
</configuration>
Step buildStep run MsTests (the path to the .dll with tests should be in ...\bin
release)
Additional steps and configurations
If we want to run the tests on a specific agent we need to specify this in Agent Requirements area.
Happy testing and... make it green, becomes a dream :).
No comments:
Post a Comment