1.2 annotations defined by junit4

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.