How to configure env variables for maven to run the test correctly?

Is it possible to install env vars in pom.xml that uses junit tests? Netbeans can get env vars and build the project in the root. But when I use the command line (mvn clean -> mvn install), the assembly fails due to test errors.

Thanks.

+4
source share
1 answer

There are two approaches that I know.

Command line:

You can pass it on the command line, for example

mvn -DAM_HOME=conf install 

Using pom:

If AM_HOM is a variable and the value is conf , enter the entry as shown below.

 <plugins> ... <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> ... <configuration> ... <environmentVariables> <AM_HOME>conf</AM_HOME> </environmentVariables> </configuration> </plugin> ... <plugins> 
+5
source

All Articles