views:

44

answers:

2

Is there a nice and simple way to get NUnit to kill a test that takes more than a specified amount of time?

Ideally it would not only kill the app domain in which the test was running, but also any child processes the test started.

+6  A: 

If you are using NUnit 2.5 you can use the Timeout attribute to fail the test after specified amount of time. Unfortunately you will need to clean all the resources yourself - e.g. in the TearDown method check if the processes are running and kill them etc.

Grzenio
A: 

This looks like a test smell. In my opinion with setting timeout you try to fight a symptom. Unit tests should be quick and reproducible (also in speed).

Why is the test taking so long? Is it even randomly "taking long" (sometimes executes fast, sometimes not)?

manuel aldana
He said child processes. I'd guess a child process is failing in a way he can't easily detect.
Rup
Currently it always takes a while. Until it's fixed (which will take time), I can either disable it or make it fail on timeout.
romkyns