diff options
Diffstat (limited to 'java/project/src/test')
-rw-r--r-- | java/project/src/test/java/ch/asynk/Test00.java | 54 | ||||
-rw-r--r-- | java/project/src/test/java/ch/asynk/TestSuite.java | 27 |
2 files changed, 81 insertions, 0 deletions
diff --git a/java/project/src/test/java/ch/asynk/Test00.java b/java/project/src/test/java/ch/asynk/Test00.java new file mode 100644 index 0000000..aae83d7 --- /dev/null +++ b/java/project/src/test/java/ch/asynk/Test00.java @@ -0,0 +1,54 @@ +package ch.asynk; + +import org.junit.Rule; +import org.junit.Test; +import org.junit.BeforeClass; +import org.junit.AfterClass; +import org.junit.rules.ExpectedException; + +import static org.junit.Assert.assertThat; +import static org.junit.Assert.assertEquals; +import static org.hamcrest.Matchers.is; +import static org.hamcrest.Matchers.hasProperty; + +import ch.asynk.MyClass; + +public class Test00 +{ + private static MyClass my; + + @Rule + public ExpectedException thrown = ExpectedException.none(); + + @BeforeClass + public static void setUpClass() + { + System.out.println(" BeforeClass : Test00"); + my = new MyClass(); + } + + @AfterClass + public static void tearDownClass() + { + System.out.println(" AfterClass : Test00"); + } + + @Test + public void test_0() + { + assertEquals("n must be equal to 666", my.getN(), 666); + } + + @Test + public void test_1() throws MyException + { + thrown.expect(MyException.class); + thrown.expectMessage("it's mine"); + my.exception(); + } + @Test + public void test_2() throws MyException + { + assertThat(my, hasProperty("n", is(666))); + } +} diff --git a/java/project/src/test/java/ch/asynk/TestSuite.java b/java/project/src/test/java/ch/asynk/TestSuite.java new file mode 100644 index 0000000..3e5d7d8 --- /dev/null +++ b/java/project/src/test/java/ch/asynk/TestSuite.java @@ -0,0 +1,27 @@ +package ch.asynk; + +import org.junit.runner.RunWith; +import org.junit.runners.Suite; +import org.junit.BeforeClass; +import org.junit.AfterClass; + +@RunWith(Suite.class) + +@Suite.SuiteClasses({ + Test00.class +}) + +public class TestSuite +{ + @BeforeClass + public static void setUpClass() + { + System.out.println("BeforeClass : TestSuite"); + } + + @AfterClass + public static void tearDownClass() + { + System.out.println("AfterClass : TestSuite"); + } +} |