Junit4's first user is an application/Business programmer. They need to easily use JUnit for unit testing. Articles on JUnit 4 User Manual, running JUnit 4 test in eclipse, unit testing with JUnit-tutorial, and some books are for them (in fact we are) prepared.
According to the separation principle of unit test classes and business classes, they need to design a unit test class. For example, the unit test class of helloworld is usually named helloworldtest. From the perspective of verifying the source code of junit4.10, we can directly writeXxxunitUnit test class with business class omitted-unless necessary.
Therefore, JUnitThe minimum package name in org. JUnitDefines a variety of common application/Business programmersAnnotation and tool class assert and assume.
Org. JUnit. Test
Org. JUnit. Ignore @ target ({elementtype. method, elementtype. Type })
@ Before and @ After can only be identified by one method, replacing the setup and teardown methods in previous JUnit versions.
Org. JUnit. beforeclass @ target (elementtype. Method)
Org. JUnit. Before @ target (elementtype. Method)
Org. JUnit. afterclass @ target (elementtype. Method)
Org. JUnit. After @ target (elementtype. Method)
Org. JUnit. Rule
Org. JUnit. classrule
More advanced use or tests requiring more code are also included with the following annotations/annotation:
Org. JUnit. Runner.Runwith@ Target (elementtype. type), run the test with the specified runner. The default runner is org. JUnit. Runners. junit4.
Org. JUnit. Runners.Suite. suiteclasses@ Target (elementtype. type), which groups all the test classes to be run into a group/suite, one-time run to facilitate the test work.
Org. JUnit. Runners.Parameterized. Parameters@ Target (elementtype. method), parameterized Test
Org. JUnit. Experimental. theories. Suppliers. testedon
Org. JUnit. Experimental. theories. datapoint
Org. JUnit. Experimental. theories. datapoints
Org. JUnit. Experimental. theories. parameterssuppliedby
Org. JUnit. Experimental. theories.Theory
Org. JUnit. Experimental. categories. categories. excludecategory
Org. JUnit. Experimental. categories. categories. includecategory
Org. JUnit. Experimental. categories.Category
Parameterization test and group test
These annotations/annotation refer to the modified unit test class as the raw material to be processed by JUnit. The meanings of these annotations/annotation and the design requirements of the framework are not provided for the time being.
1.2 annotations defined by junit4