Rev | Line | |
---|
[481] | 1 | package testcode;
|
---|
| 2 |
|
---|
| 3 | import static org.junit.Assert.assertEquals;
|
---|
| 4 |
|
---|
| 5 | public class AssertTest {
|
---|
| 6 |
|
---|
| 7 | public AssertTest() {
|
---|
| 8 | test1();
|
---|
| 9 | test2();
|
---|
| 10 | }
|
---|
| 11 |
|
---|
| 12 | /**
|
---|
| 13 | * The test code for Value
|
---|
| 14 | *
|
---|
| 15 | * @throws Exception
|
---|
| 16 | */
|
---|
| 17 | public static void main(String[] args) throws Exception {
|
---|
| 18 | new AssertTest();
|
---|
| 19 | }
|
---|
| 20 |
|
---|
| 21 | public static void test1() {
|
---|
| 22 | assertEquals(1, 1);
|
---|
| 23 | System.out.println("1ok");
|
---|
| 24 | }
|
---|
| 25 |
|
---|
| 26 | public static void test2() {
|
---|
| 27 | try {
|
---|
| 28 | assertEquals("not equal", 1, 2);
|
---|
| 29 | System.out.println("Test did not fail properly");
|
---|
| 30 | return;
|
---|
| 31 | } catch (AssertionError e) {
|
---|
| 32 | if (!e.getMessage().contains("not equal")) {
|
---|
| 33 | System.out.println(
|
---|
| 34 | "Test threw as expected but message does not contain 'not equal'");
|
---|
| 35 | return;
|
---|
| 36 | }
|
---|
| 37 | System.out.println("2ok");
|
---|
| 38 | }
|
---|
| 39 | }
|
---|
| 40 | } |
---|
Note:
See
TracBrowser
for help on using the repository browser.