How to Get Faster Test Tasks in Your Azure DevOps Pipeline

A side effect we noticed after the migration to .Net 6 was that the test task in Azure DevOps took a lot longer than before. The test execution itself did not change much, but the dotnet test task had much more overhead than vstest. As an example, the test task took 4m 48s, while the test execution only took 1m 34s – giving us an overhead of 3m 14s or roughly 75% of the total time:

The pipeline took a lot more time than the test run.

While we expect a certain overhead, it should not be that much. Especially when we consider how often we run our tests.

After a long search and various attempts that did not shorten the runtime, we settled with these additional parameters:

This should prevent the test task from restoring and recompiling the test code and instead use the already compiled artefacts from the build task a few steps above in the pipeline.

This cut the time to run our test task to 2m 26s and saved us nearly half of the initial time:

The test task is now significantly faster while the test execution stayed the same.

Should your tests take longer as usual, try this quick optimisation before you explore other options.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.