01: package org.hanselexample;
02:
03: import org.junit.Test;
04: import static org.junit.Assert.*;
05:
06: /**
07: * Coverage Test for the Example class.
08: * This test covers all lines (including private/anonymous classes)
09: * of the Example class.
10: *
11: * @author Niklas Mehner
12: */
13: public class ExampleJUnit4Test {
14:
15: @Test
16: public void absTest() {
17: Example example = new Example();
18: assertEquals("abs(1) should be 1.", 1, example.abs(1));
19: assertEquals("abs(-1) should be 1.", 1, example.abs(-1));
20: assertEquals("abs(0) should be 0.", 0, example.abs(0));
21: }
22:
23: /**
24: * Test the Example.add() method. This also covers the code of the inner
25: * class.
26: */
27: @Test
28: public void innerClassTest() {
29: Example example = new Example();
30: assertEquals("add(2, 3) should be 5.", 5, example.add(2, 3));
31: }
32: }
|