One of the interesting challenges that we have with RavenDB is the number and duration of our tests.
In particular, we current have over three thousands tests, and they take hours to run. We are doing a lot of stuff there “let us insert million docs, write a map/reduce index, query on that, then do a mass update, see what happens”, etc. We are also doing a lot of stuff that really can’t be emulated easily. If I’m testing replication for a non existent target, I need to check that actual behavior, etc. Oh, and we’re probably doing silly stuff in there, too.
In order to try to increase our feedback cycle times, I made some modifications to xUnit. It is now going to record the test duration of the tests, the results look like that:
You can see that Troy is taking too long. In fact, there is a bug that those tests currently expose that result in a timeout exception, that is why they take so long.
But this is just to demonstrate the issue. The real power here is that we also use this when decided how to run the tests. We are simply sorting them by how long they took to run. If we don’t have a record for that, we’ll give them a run time of –1.
This has a bunch of interesting implications:
- The faster tests are going to run first. That means that we’ll have earlier feedback if we broke something.
- The new tests (haven’t had chance to run ever) will run first, those are were the problems are more likely anyway.
- We only run report this for passing tests, that means that we are going to run failed tests first as well.
In addition to that, this will also give us better feedback on what are slow tests are. So we can actually give them some attention and see if they are really required to be slow or they can be fixed.
Hopefully, we can find a lot of the tests that are long, and just split them off into a separate test project, to be run at a later time.
The important thing is, now we have the information to handle this.