JUnit Question

Rusting In Peace

Distinguished
Jul 2, 2009
312
0
19,060
No tests don't return values; tests throw exceptions! Throwing the correct exception will deem the test as failed due to your test condition not being as you expect (rather than a run time exception). No exception means the test has passed - hence why an empty test method returning nothing will pass.

Use the Assert class to state what result you expect for example:

Code:
@Test
public void testAddition() {
	Assert.assertTrue("1 and 2 should make 3", (1 + 2) == 3 );
}