To add a system property to JUnit tests, configure Maven Surefire Plugin as follows:
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <systemPropertyVariables> <java.library.path>${project.basedir}/src/main/native/Authenticator/Release</java.library.path> </systemPropertyVariables> </configuration> </plugin> </plugins> </build>
Update:
Well, it looks like this property should be set before starting the JVM with JUnit checks. Therefore, I assume that you have backslash problems. Backslashes in the value of a Java property are used to call special characters, such as \t (tab) or \r\n (newline windows). So try using this instead of your solution:
<build> <plugins> <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <forkMode>once</forkMode> <argLine>-Djava.library.path=${project.basedir}/src/main/native/Authenticator/Release</argLine> </configuration> </plugin> </plugins> </build>
Jiri patera
source share