程序包 org.junit
Provides JUnit core classes and annotations. Corresponds to junit.framework in Junit 3.x.
- 从以下版本开始:
- 4.0
异常错误概要 异常错误 说明 AssumptionViolatedException An exception class used to implement assumptions (state in which a given test is meaningful and should or should not be executed).错误概要 错误 说明 ComparisonFailure Thrown when anassertEquals(String, String)
fails.注释类型概要 注释类型 说明 After If you allocate external resources in aBefore
method you need to release them after the test runs.AfterClass If you allocate expensive external resources in aBeforeClass
method you need to release them after all the tests in the class have run.Before When writing tests, it is common to find that several tests need similar objects created before they can run.BeforeClass Sometimes several tests need to share computationally expensive setup (like logging into a database).ClassRule Annotates static fields that reference rules or methods that return them.FixMethodOrder This class allows the user to choose the order of execution of the methods within a test class.Ignore Sometimes you want to temporarily disable a test or a group of tests.Rule Annotates fields that reference rules or methods that return a rule.Test TheTest
annotation tells JUnit that thepublic void
method to which it is attached can be run as a test case.