Maven Surefire @BeforeClass is executed before each test
I am trying to use annotation @BeforeClass
to initialize data and DB connection. But when I run my test with mvn test
, I notice that the annotated static method @BeforeClass
is executed for each test.
I don't understand why the static method is not executed once for the test class?
My parent pom contains the following configuration for the maven surefire plugin:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.13</version>
<configuration>
<useSystemClassLoader>false</useSystemClassLoader>
<systemPropertyVariables>
<properties.path>${properties.path}</properties.path>
<dico.path>${dico.path}</dico.path>
</systemPropertyVariables>
<!-- On ne joue pas les tests d'integrations -->
<excludes>
<exclude>**/**ITCase.java</exclude>
</excludes>
</configuration>
</plugin>
+3
source to share
No one has answered this question yet
Check out similar questions: