views:

249

answers:

3

I am using NUnit (2.4.6) and my build/test night are done with Team City 4. I have contacted team city and they already told me that they cannot handle this. So, here I am.

What I want is to set up my test to do their testing as usual but in the case they hang up... for an unknown reason (this might happen...)... I do not want them to continue but to fail. This is require because sometime I have notice my build night was done and when testing arrive some test hang up for the whole night.

How would you do it?

Have in mind that I know that Nunit 2.5 (Beta) have the MaxTime attribute but I would have to upgrade + do it over 800 units tests... I would like something for the whole tests without having to upgrade to this beta version yet.

A: 

I'd use the MaxTime as you suggest, that's the standard way of doing it - why bother to create something new just to avoid updating the tests themselves?

If the problem is simply the amount of time taken to update the tests, personally I'd probably knock up some quick and dirty program to parse the source files and add the attribute. There are probably better way of updating the code (generators or whatever), but that would work.

Unless there's a compelling reason not to use NUnit 2.5?

Ayresome
I think his problem was with moving to NUnit 2.5 beta, not with adding the attribute
orip
+2  A: 

TC has an execution timeout for each build configuration, which fails the build if exceeded. It's in general settings "fail build if it runs longer than". It's not per unit test, but I think it's good enough for your scenario.

Meidan Alon
+1  A: 

If you're dead set against upgrading to 2.5 there is a MaxTimeDecorator in the NUnit samples which will fail the test if takes longer than the specified time. Obviously this won't help when the test hangs, but you can probably modify the sample so it spawns off the test in its own thread and has a call back every so often to see if the time limit has been exceeded. This however would get rather complicated very quickly.

Joshua