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
java maven junit maven-surefire-plugin


source to share


No one has answered this question yet

Check out similar questions:

2240
How to create an executable JAR with dependencies using Maven?
205
Maven correct could not find ForkedBooter class
22
Running JUnit tests contained in a dependency tank using Maven Surefire
20
Surefire does not run test in src / main / java
13
Running tests using maven packaging type "pom"
4
How to execute method once before running maven surefire
2
maven surefire-plugin skips tests
1
Maven Surefire not executing test phase
0
Maven Surefire only "default-test" runs custom executions ignored
0
Surefire-report-plugin generates a report containing the results of the last test



All Articles
Loading...
X
Show
Funny
Dev
Pics