I. About JUnit
JUnit is a unit test framework for the Java language. Founded by Kent Beck and Erich Gamma, it became the most successful of the Xunit family of Sunit from Kent Beck.
JUnit is a regression testing framework (regression testing framework) written by Erich Gamma and Kent Beck. JUnit testing is a programmer's test, the so-called white-box test, because the programmer knows how the software being tested (how) accomplishes the function and what it does.
Two. get JUnit
download to the latest version of JUnit at Http://www.junit.org .
Three. Examples of JUnit
Four. New and old comparisons of JUnit
-junit3
1. The Unit test class must inherit from the Junit.framework.TestCase class
2. The method name to be tested must begin with test, must be public void and cannot have parameters
-junit4
1. Unit test classes do not have to inherit testcase
2. The test method does not have to be preceded by test, as long as the @test metadata is used to describe
-Metadata (Annotation)--the data used to describe the data.
@Before: Methods that use this metadata are executed one time before each test method executes.
@After: Methods that use this metadata are executed once after each test method executes.
@Test (Expected=*.class): Used to throw an exception.
@Test (TIMEOUT=XXX):
The metadata passed in a time (in milliseconds) to the test method,
If the test method does not run out within the time set, the test also fails.
@ignore:
The test method for the metadata token is ignored in the test.
You can pass a string argument to the label to indicate that the reason is ignored.
First knowledge of JUnit