views:

422

answers:

4
+1  A: 

Compile with -Xlint on. It will complain about missing @Override's or @Overrides in the wrong place.

anio
+5  A: 

Using the Override annotation in that kind of tests is perfectly valid, but the annotation has no specific relationship to testing at all; It can (and should) be used all over production code as well.

Michael Borgwardt
yes I've no problem using it in production code
Rich Seller
A: 

@Override ensures that you in fact override the method rather than accidentally overload it, and the compiler warning helps you determine if you overrode a method you intended to overload.

Using it in this case is perfectly legitimate, but given that it is a test, the test should fail if you overload the method instead of overriding it (say change the method signature), so perhaps it isn't important in this case.

Yishai
+1  A: 

The purpose of @Override is that you declare your intent to override a method, so that if you make a mistake (e.g. wrong spelling of the method name, wrong argument type) the compiler can complain and you find your mistake early.

So this is a perfectly valid use.

starblue