You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
There will be a way to run methods prior to and after all tests in a
TestCase class. In contrast to setUp() and tearDown() they will be run
only once per class and not once per test.
Rationale
Initialize and dispose of resources that are expensive to create, e.g.
a server instance, a network connection, ...
Functionality
Note
This can violate the principle that unittest should be independent. For
some cases though this might be a necessary optimization to meet the
goal that unittests should run fast - for other situations, setUp() and
tearDown() serve this purpose.
Annotations
The functionality can be used by annotating public static methods with
the @beforeClass and @afterclass annotations.
Scope of Change
There will be a way to run methods prior to and after all tests in a
TestCase class. In contrast to setUp() and tearDown() they will be run
only once per class and not once per test.
Rationale
Initialize and dispose of resources that are expensive to create, e.g.
a server instance, a network connection, ...
Functionality
Note
Annotations
The functionality can be used by annotating public static methods with
the @beforeClass and @afterclass annotations.
Example
Timeline
When a test suite is run, the following is performed for each test class
added to the suite:
Definitions
in that class are run (and instead marked as skipped).
Security considerations
n/a
Speed impact
Slightly slower because of additional checks.
Dependencies
none.
Related documents
http://junit.sourceforge.net/javadoc_40/org/junit/BeforeClass.html
http://junit.sourceforge.net/javadoc_40/org/junit/AfterClass.html
http://testng.org/doc/documentation-main.html#annotations
http://xp-framework.net/rfc/contrib/rfc0150.diff
The text was updated successfully, but these errors were encountered: