KevinUp

real world programming

TimeoutAttribute

Posted by kevinup on December 12, 2007

Our dev environment is down, something about Java not having enough beans. Anyway I can’t stand not running unit tests, so I’ve pointed our testing framework to our QA environment. I discovered some interesting things about our QA environment, like there was some seed data that wasn’t there, but the more interesting thing is how un-optimal some of our code is. Some code that was running in 400 MS on dev was taking 30 minutes in QA. It was a pain tracking down the culprit. I usually run our test locally using nunit console and ncover

I wish I could press a hot key and fail the current running test. Or have a command line parameter that sets the timeout for all the tests. I started thinking, there HAS to be a test attribute to set a tests timeout. I started looking around, and found the Holy Grail TimeoutAttribute Class , figures it’s called Timeout , duh. It works like this:

[TestMethod]
[Timeout(10000)]
public void EmployeeOrderHistoryReport()

The Timeout attribute take how many milliseconds to run the test. If the test takes more than that many milliseconds it times out. So now I’m going though my tests, and decorating the necessary test with Timeout attributes. Reminding me to come back through and add some performance improvements later.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

 
%d bloggers like this: