JUnit Question

Rusting In Peace

Distinguished
Jul 2, 2009
313
0
19,060
34
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 );
}
 
Thread starter Similar threads Forum Replies Date
S Apps General Discussion 1
M Apps General Discussion 0
M Apps General Discussion 0
R Apps General Discussion 0
M Apps General Discussion 1
S Apps General Discussion 1
T Apps General Discussion 10
T Apps General Discussion 2
H Apps General Discussion 1
B Apps General Discussion 2
L Apps General Discussion 1
N Apps General Discussion 5
T Apps General Discussion 1
N Apps General Discussion 3
M Apps General Discussion 3
P Apps General Discussion 2
appletatoes Apps General Discussion 3
M Apps General Discussion 1
B Apps General Discussion 7
tjones9163 Apps General Discussion 2

ASK THE COMMUNITY