Daily Usage Issues

Terminate test runners without "resynchronize" ?

Started by GreenMoose on 5,726 views

Hi,

Background
We have some tests with static data and ioc containers which does not gracefully handle test failures.
In NCrunch I can have the option of setting "Terminate test runner tasks when all test execution is complete" to True/False.
If I set it to True, every startup of test run process takes ~10s due to static initialization routines.
If I set it to False, rerunning a test within same test process is very fast (since static initialization routines are already done), but sometimes when tests fail our static ioc container usage does not handle this well so all suceeding tests in same test runner process will fail due to "ioc container error".

Question
So, If I have above setting to "False", can I somehow reset the test runner processes gracefully without having to rebuild/rerun all tests?

Thanks.
Hi,

State corruption from failed tests is a fairly common problem, although it is quite a difficult one for NCrunch itself to handle (as NCrunch cannot make safe assumptions about the workings of your source code). The first thing I would suggest is to try and find a way to solve this problem in the source code itself, as this will ultimately give you the best result - there are few things more frustrating than having long lines of failing tests because a single test happened to cause state corruption. If the nature of the failing tests are such that it isn't possible to reliably repair their state after failure, it may be worth looking into test set up code that inspects the state of the process before executing each test, and repairing it if there is a problem (i.e. re-initialize the process via invoking the code you currently have in the static blocks).

But anyway, I assume you've already looked into options for the above and that you're looking for a configuration setting or something that can take the pain away from NCrunch's side. I can't think of anything that will directly do this, but I may be able to suggest a faster way to handle the problem without needing to reset the whole engine.

NCrunch's usage of test/build processes is very resilient. Before trying to re-use an existing process that was used for a previous test run, NCrunch will always check first whether the process still exists. If the process has died for whatever reason (i.e. user killed it?), NCrunch will simply discard it and create a new one. This means that after you have a test that fails due to state corruption, there's no need to reset the entire engine and wait for the reload - you just need to make use the nCrunch.TestHost.*.exe processes get killed.

It's painful to do this manually using task manager or process explorer. The most convenient way would probably be to use a powershell script/command such as:

get-process nCrunch.TestHost.* | stop-process

You could try binding this to a shortcut or something to make it easy to access. I hope it does the trick!


Cheers,

Remco

Post a reply

Log in to reply.