Step-by-step testing TeamCity for .Net projects
I am creating a modular WPF application. Each screen is a very independent and isolated device. The only thing shared is a wrapper and shared library with a facade interface for reusable services (message bus, persistence, window management, etc.).
Since modules are loosely coupled, it makes no sense to repeat everything when one module has changed. I only want to check what has changed. If there is a change in the shared library, everything should be checked.
From the source control diff, you can easily get a list of the files that have changed and thus resolve the affected projects (csproj files have all the files to compile). You can also resolve project dependencies on csproj files (who uses it, who touched it). All this information should be sufficient to tell you what actually needs testing. So the problem sounds solvable.
Has anyone done this with TeamCity? Any suggestions? I saw there is a solution for Java users: http://blog.jetbrains.com/teamcity/2012/03/incremental-testing-with-teamcity/
How about the .net domain?
source to share
You need to create build configurations and generate artifacts and run tests.
For example, you have a project Library
, Library.Tests
, Portable
, Poratble.Tests
, App
and App.Tests
.
You need to create a build configuration (for example Library build
) that compiles projects Library
and Library.Test
. This configuration generates artifacts like eg. libtests.zip
...
Then you create another build configuration (for example Run Library Tests
) and install the snapshot and artifact dependency in the previously created configuration Library build
. In this test configuration, you unpack the file libtests.zip
(derived from the artifact dependency) and create a build step (like an NUnit runner) to run those tests.
Be careful: you only want to run tests when something changes in the library, so under Version Control Settings, check Show changes from snapshot dependencies
and create a new VCS trigger that will be Trigger on changes in snapshot dependencies
(also a checkbox).
Then suppose that Portable
depends on Library
and has its own test suite.
Again, you have to create a build config that will compile projects Portable
and Portable.Tests
and generate artifacts called eg.portabletests.zip
Again, you create a different build configuration to run these tests in the same way as the previous ones. only this time you need to add another snapshot dependency on config Build library
and Run Library Tests
. With this additional snapshot dependency, you will achieve that the code is compiled and run only when the library build and testrun are in order.
The same applies to App
and App.Tests
.
So ... When there is a change in the library, the entire set is rebuilt, and all tests are performed ( Library.Tests
, Portable.Tests
, App
, App.Tests
). When Portable
there is a change in the code , it gets run Bulid portables
and started Portable.Tests
, and App
+ App.Tests
is recompiled and App.Tests
.
From this link you can read more about snapshot and artifact dependencies at teamcity http://confluence.jetbrains.com/display/TCD8/Configuring+Dependencies
source to share