Test Performance: Resolution

time to read 2 min | 276 words

I've one test class that takes over a minute to execute(!), that is unacceptable. Taking a look inside, I can see why this is so, it construct the database and creates an AppDomain on each and every test. Moving those to the TestFixtureSetup made it run in 1.6 seconds, which I consider far better.

The second offender took only 22 seconds to run, also for the same reason, moving to TestFixtureSetup can it down to 1.5, which is much better. The other main offender was 10 seconds (down to 0.67).

It took me 30 minutes, and I cut the time to run my test suite from over 140 seconds to 27 seconds, but that is still not enough.

One class is testing the AppDomain load/unload, so there isn't much that can be done about it, but I still managed to move it from 10 seconds to 5.

The next thing to tackle was 14.5 seconds spent on UI testing. I've commented before, databases and networking may be slow, but until you look at the timing for UI tests, you won't believe how slow the UI is.

Considerring my previous diffculities with testing the UI, I removed those tests all together, and removed the reference to MbUnitForms.

Total time to run the tests before "optimization"*: 140+ Secodns.
Total time to run the test after "optimization"*: 11.45 seconds.

Now I no longer have to look for something else to do while I'm running the tests. :-)