Welcome Guest! To enable all features please Login or Register.

Notification

Icon
Error

Terminate test runners without "resynchronize" ?
GreenMoose
#1 Posted : Friday, May 17, 2013 11:14:09 AM(UTC)
Rank: Advanced Member

Groups: Registered
Joined: 6/17/2012(UTC)
Posts: 507

Thanks: 145 times
Was thanked: 66 time(s) in 64 post(s)
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.
Remco
#2 Posted : Friday, May 17, 2013 10:40:08 PM(UTC)
Rank: NCrunch Developer

Groups: Administrators
Joined: 4/16/2011(UTC)
Posts: 7,123

Thanks: 957 times
Was thanked: 1286 time(s) in 1193 post(s)
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
Users browsing this topic
Guest
Forum Jump  
You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.

YAF | YAF © 2003-2011, Yet Another Forum.NET
This page was generated in 0.034 seconds.
Trial NCrunch
Take NCrunch for a spin
Do your fingers a favour and supercharge your testing workflow
Free Download