Daily Usage Issues

Automatically run impacted tests without automatically running all tests

Started by distilled on 2,220 views

I use NCrunch in a solution with a large number of tests (~20k). I prefer to leave NCrunch in the "Automatically run impacted tests" mode. However, when I select this mode NCrunch automatically runs all unignored tests right away, before only running tests that are impacted by my changes. Is there a way to disable this initial run without just ignoring all of my tests and then selectively unignoring the ones that I think I might impact?
Hi, thanks for posting.

If you're using the 'Run impacted tests automatically, others manually' mode, NCrunch should only run tests when it detects that they are impacted by IL-level changes in your code.

This includes after the engine is started. NCrunch does this by storing the hash state of your codebase in its cache file and comparing this to the state of the codebase after the engine has switched on. Tests that cover the changes areas are considered impacted and are executed.

The same process is used when the mode is switched to this one.

So I guess what I'm saying is that if things are working properly, then this is the sort of behaviour you should already be seeing.

Can you confirm exactly which engine mode you are switching to and what its settings are?
So I guess what I'm saying is that if things are working properly, then this is the sort of behaviour you should already be seeing.


Yep, I can confirm that that's what I'm seeing. I guess in my experience the file hash very rarely matches what NCrunch has cached, and most of the time when I launch VS I need to quickly disable NCrunch or tell it to ignore everything so that it doesn't try to start running all of the tests.
distilled wrote:
Yep, I can confirm that that's what I'm seeing. I guess in my experience the file hash very rarely matches what NCrunch has cached, and most of the time when I launch VS I need to quickly disable NCrunch or tell it to ignore everything so that it doesn't try to start running all of the tests.


The hashing system is very sensitive to even the smallest of IL changes in the code. If you regularly update from a VCS before opening your codebase, you'll likely see tests get triggered every time a changeset comes down. If you have a lot of long running tests that NCrunch is running a bit too eagerly, you might want to consider setting up your own engine mode that separates them out to be executed manually.
I'll give customizing the engine a shot. Thanks!

Post a reply

Log in to reply.