Instead of something like this:
Code: Select all
if (a == null || b == null || a != b) {
throw new Exception(...);
} else {
// do Something
}
Code: Select all
Assert.assertNotNull("a is not allowed to be null", a);
Assert.assertNotNull("b is not allowed to be null", b);
Assert.assertEquals("a has to be equal to b", a, b);
// do Something
http://www.junit.org/apidocs/org/junit/Assert.html