Java – Unit Testing Competition

javajavascriptseleniumunit testing

My employers runs a monthly unit testing day competition. One entire day is dedicated to writing unit tests — obviously we do more testing throughout the month, but this is an entire day — and the "winner" of the competition is given a prize. However, we are finding it's hard to determine who the winner is.

We were assigning points for each test case. So if you wrote a unit test like this…

for (int i = 0; i < 100; i++) {
  assertTrue(i*i, square(i));
}

you would be given 100 points. Obviously this is a simplistic example but it demonstrates the problems with assigning "points" to each test case.

We're primarily a Java & Javascript shop. So I suggested counting number of code branches tested as a metric. We can easily count the branches tested via a code coverage tool (such as EclEmma). However, not sure how we would do this with our Selenium tests and getting a code coverage on the Javascript sources (any ideas?)

Does anyone have any suggestions on how we could better determine the winner of this competition?

Edit

I know how to write unit tests, I know how to write effective unit tests, I don't need help determining what to test. I have no control over this competition — the competition will go on. So either I add some input to make it better or carry on gaming the tests (yeah, I game them. Of course I game them. There are prizes to be won)

Edit

This question here is obviously not a duplicate, though it contains useful information about how to find good test cases, it does not provide any useful metrics to evaluate the competition.

Best Answer

Does anyone have any suggestions on how we could better determine the winner of this competition?

The only thing which makes sense to me is by voting - every dev can assign some points to every other dev's test (except his own). Maybe 3 points for the test he thinks it is the "most effective" one, 2 points for the second and one to the third. The test with the most points wins. It may give better results when the point assignment is done without knowing beforehand who wrote the particular test.

As a bonus, you will get all your tests peer reviewed.

Related Topic