package org.sample.junit; import static org.junit.Assert.*; import static org.hamcrest.CoreMatchers.*; import org.junit.After; import org.junit.AfterClass; import org.junit.Before; import org.junit.BeforeClass; import org.junit.Test; import org.junit.experimental.categories.Category; import org.sample.junit.category.SlowTests; public class SampleTest1 { @BeforeClass public static void setUpBeforeClass() throws Exception { System.out.println("setUpBeforeClass"); } @AfterClass public static void tearDownAfterClass() throws Exception { System.out.println("tearDownAfterClass"); } @Before public void setUp() throws Exception { System.out.println("setUp"); } @After public void tearDown() throws Exception { System.out.println("tearDown"); } /* 通常テスト */ @Test public void test1() { System.out.println("#test"); int actual = 1; int expect = 1; assertThat(actual, is(expect)); } /* Throwされた例外をテスト */ @Test(expected= NullPointerException.class) public void testThrow() throws Exception { System.out.println("#testThrow"); throw new NullPointerException(); } }