@BeforeClass: Difference between revisions

From NovaOrdis Knowledge Base
Jump to navigation Jump to search
(Created page with "=Internal= * JUnit =Overview= The annotation must be attached to a '''static''' method.")
 
Line 6: Line 6:


The annotation must be attached to a '''static''' method.
The annotation must be attached to a '''static''' method.
If two methods '''with different names''' are annotated with <code>@BeforeClass</code> in a test class hierarchy, as shown below:
<font size='-1'>
TestBase.java
  │  @BeforeClass
  │  public static void methodA() {
  │    ...
  │  }
  │
  └── SomeTest.java
          @BeforeClass
          public static void methodB() {
            ...
          }
</font>

Revision as of 01:45, 29 August 2021

Internal

Overview

The annotation must be attached to a static method.

If two methods with different names are annotated with @BeforeClass in a test class hierarchy, as shown below:

TestBase.java
  │  @BeforeClass
  │  public static void methodA() {
  │     ...
  │  }
  │
  └── SomeTest.java
          @BeforeClass
          public static void methodB() {
            ...
          }