I'm building a modular WPF application. Each screen is a highly independent and isolated unit. The only thing shared - shell and a common library with a facade interface for the reusable services (message bus, persistence, window management etc).
Since the modules are loosely coupled it doesn't make sense to retest everything when a single module changed. I want to test only what's changed. If there is a change in a common library - everything should be retested.
From a source control diff you can easily get a list of files changed and thus resolve the projects affected (csproj files has all the files to compile listed). You can also resolve the project dependencies from the csproj files (who's using it, who's affected). All this info should be enough to tell 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 folks: http://blog.jetbrains.com/teamcity/2012/03/incremental-testing-with-teamcity/
What about the .net realm?
You have to create build configurations and that generate artefacts and run tests.
For example you have projects
Library
,Library.Tests
,Portable
,Poratble.Tests
,App
andApp.Tests
.You have to create build configuration (eg.
Library build
) that compilesLibrary
andLibrary.Test
projects. This configuration generates artefactes lets say eg.libtests.zip
.Then you create another build configuration (eg.
Run Library Tests
and set the snapshot and artefacts dependency on previously createdLibrary build
configuration. In this test running configuration you have unpacking thelibtests.zip
file (gathered from the artefacts dependency) and create a build step (eg. NUnit runner) to run those tests.Be careful: You want to run tests only when something changes in Library, so under "Version Control Settings" check the
Show changes from snapshot dependencies
and create new VCS Trigger that willTrigger on changes in snapshot dependencies
(also a checkbox).Then, lets assume
Portable
is dependent onLibrary
and have its own suite of tests.Again, you should create build configuration that will compile projects
Portable
andPortable.Tests
and generate artefacts called eg.portabletests.zip
And yet again you create another build configuration for running this tests the same as previous. only this time you should add another snapshot dependency on
Build library
andRun library tests
configuration. With this additional snapshot dependency you will achieve that code is compiled and run only when library build and testrun is OK.Same goes for
App
andApp.Tests
.So... When change occures in Library the whole set is rebuild and all tests are run (
Library.Tests
,Portable.Tests
,App
,App.Tests
). When change happens inPortable
code,Bulid portables
is triggered andPortable.Tests
are run andApp
+App.Tests
are recompiles andApp.Tests
are run.On this link you can learn more about snapshot and artefacts dependencies in teamcity http://confluence.jetbrains.com/display/TCD8/Configuring+Dependencies