Surefire JUnit Testing using Native Libraries

后端 未结 1 1964
清歌不尽
清歌不尽 2021-01-17 21:42

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 projec

相关标签:
1条回答
  • 2021-01-17 21:49

    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>
    
    0 讨论(0)
提交回复
热议问题