1.

What is the purpose of the @AfterClass annotation in JUnit?

Answer»

In CASE of the ALLOCATION of the expensive external resources in a BeforeClass method, then there is the requirement of releasing them after the running of the tests completes. For this, the annotation of the @AfterClass method, a public static void method is required to be run after all the class’s tests have been run. It is because of the feature of the method such as it guarantees the test is running even in the SITUATION of an EXCEPTION thrown by BeforeClass. It is one of the methods to be declared in the superclass and run after the running process of the current class ends. Also, it is called once per test class.

6. What are JUnit annotations?

The SPECIAL form of the syntactic meta-data that can be used for the improved code readability and structure in the source code. The examples of the entities that can be annotated are parameters, methods, variables, classes, and methods in the Java source code. JUnit annotations are Before, After, AfterClass, Ignore, BeforeClass, RunWith, and Test.



Discussion

No Comment Found