Surefire JUnit Testing using Native Libraries

冷暖自知 提交于 2019-12-01 16:04:31

To add a system property to the JUnit tests, configure the 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:

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:

<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>
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!