We are using Maven in Hudson to run our Java build process and the Surefire plugin to execute JUnit tests however I’ve run into a problem with the unit tests for one project which requires native dlls.
The error we’re seeing is :
Tests in error: TestFormRegistrationServiceConnection(com.#productidentifierremoved#.test.RegistrationServiceTest): no Authenticator in java.library.path
Where Authenticator is the name of the dll we require.
I found this SO post which suggest that the only way to set this is through argLine. We modified our config to this:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-report-plugin</artifactId>
<version>2.10</version>
<configuration>
<forkMode>once</forkMode>
<argLine>-Djava.library.path=${basedir}\src\main\native\Authenticator\Release</argLine>
</configuration>
</plugin>
However this still gives the same error and if we include a System.out.println(System.getProperty(“java.library.path”)); we can see that this is not being added to the path.
Any ideas how we can solve this?
To add a system property to the JUnit tests, configure the Maven Surefire Plugin as follows:
Update:
Ok, it seems this property has to be set before the JVM with JUnit tests starts. So I guess that you have problem with the backslashes. Backslashes in the Java property value are used to escape special characters like
\t(tabulator) or\r\n(windows new-line). So try to use this instead of your solution: