8. ? JUnit 4.x ??(??? 4.x? ?? ??)
- Java 5?? ?? ??.(1.5)
- ????? ??.
- Hamcrest ??.
- ????, ??, ????
3.x VS 4.x
Feature JUnit 3.x JUnit 4.x
test annotation testXXX pattern @Test
run before the first test method in the current
class is invoked
None @BeforeClass
run after all the test methods in the current cla
ss have been run
None @AfterClass
run before each test method override setUp() @Before
run after each test method override tearDown() @After
ignore test Comment out or remove code @ignore
expected exception catch exception assert s)uccess @Test(expected = ArithmeticException.class)
timeout None @Test(timeout = 1000
@Test
???? ??? ???? ???? ???? ???? ???? ??? ??? ??? test? ???? ??? ??? ???.
JUnit4.x? ??? ??? ??? ???? @Test ?????? ??? ??? ???? ??.
@Before / After
??? ??? ???? JUnit4.x ??? ??? @Before? @After?? ??? ??????? ??.