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:
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:
1 |
--no-restore --no-build |
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:
Should your tests take longer as usual, try this quick optimisation before you explore other options.