Maven 验证集成测试没有找到被测工件
Maven verifier intergration tests don't find artifact under test
我有一个 maven 项目(github) that uses the Maven integration test verifier 广泛。
测试是指我正在测试的项目。例如,这个 pom 会:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4.1</version>
<dependencies>
<dependency>
<!-- My project which customizes the plugin. -->
<groupId>com.google.security</groupId>
<artifactId>fences-maven-enforcer-rule</artifactId>
<version>1.2-beta-SNAPSHOT</version>
</dependency>
</dependencies>
...
其中依赖于相对路径 ../../../../../pom.xml.
然后我的 junit test 使用 Verifier
到 运行 集成测试。
// testProjectName is the basename of the directory
// containing the POM above.
File testDir = ResourceExtractor.simpleExtractResources(
getClass(), "/" + testProjectName);
Verifier verifier = new Verifier(
testDir.getAbsolutePath(),
null, debug == Debug.VERBOSE, true /* forkJvm */);
// Clean up after previous runs.
verifier.deleteArtifacts("test");
Result goalResult = Result.PASS;
try {
verifier.executeGoal("verify");
} catch (@SuppressWarnings("unused") VerificationException ex) {
goalResult = Result.FAIL;
}
我可以通过 mvn install -DskipTests=true && mvn test
来测试它,但这不太理想,因为如果我在不重新安装的情况下更改代码,我最终会 运行ning 测试过时的版本, 因为第一次下载项目的人不能只做 mvn test
.
是否有一些方法可以调整 POM 或 junit TestCase,以便依赖于刚刚编译为 target/classes
的 类?
您需要在构建依赖项之前构建并安装依赖项,或者两者都必须属于同一个反应器构建。我认为如果它在同一个模块中它不起作用(至少不具有工件依赖性,测试 classes 自动在测试 class 路径上 - 但插件可能无法从那里加载).
我有一个 maven 项目(github) that uses the Maven integration test verifier 广泛。
测试是指我正在测试的项目。例如,这个 pom 会:
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-enforcer-plugin</artifactId>
<version>1.4.1</version>
<dependencies>
<dependency>
<!-- My project which customizes the plugin. -->
<groupId>com.google.security</groupId>
<artifactId>fences-maven-enforcer-rule</artifactId>
<version>1.2-beta-SNAPSHOT</version>
</dependency>
</dependencies>
...
其中依赖于相对路径 ../../../../../pom.xml.
然后我的 junit test 使用 Verifier
到 运行 集成测试。
// testProjectName is the basename of the directory
// containing the POM above.
File testDir = ResourceExtractor.simpleExtractResources(
getClass(), "/" + testProjectName);
Verifier verifier = new Verifier(
testDir.getAbsolutePath(),
null, debug == Debug.VERBOSE, true /* forkJvm */);
// Clean up after previous runs.
verifier.deleteArtifacts("test");
Result goalResult = Result.PASS;
try {
verifier.executeGoal("verify");
} catch (@SuppressWarnings("unused") VerificationException ex) {
goalResult = Result.FAIL;
}
我可以通过 mvn install -DskipTests=true && mvn test
来测试它,但这不太理想,因为如果我在不重新安装的情况下更改代码,我最终会 运行ning 测试过时的版本, 因为第一次下载项目的人不能只做 mvn test
.
是否有一些方法可以调整 POM 或 junit TestCase,以便依赖于刚刚编译为 target/classes
的 类?
您需要在构建依赖项之前构建并安装依赖项,或者两者都必须属于同一个反应器构建。我认为如果它在同一个模块中它不起作用(至少不具有工件依赖性,测试 classes 自动在测试 class 路径上 - 但插件可能无法从那里加载).