通过failsave在pom.xml中使用自定义Java注释



我创建了一个自定义Java注释

@Tag("webservice")
public @interface WebserviceTest {
boolean executeAndIgnoreCondition() default false;
}

此外,我用这个注释创建了Java测试。现在我想运行failsave,但只测试带有注释'WebserviceTest'的测试。

我试了很多,但没有一个是好的。最后一个例子:

<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-failsafe-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>
integration-test
</goal>
<goal>
verify
</goal>
</goals>
</execution>
</executions>
<configuration>
<includes>
<include>**/Test*.java</include>
</includes>
<groups>webservice</groups>
</configuration>
</plugin>

如果我用

注释测试
@Tag("webservice")

一切都很好,但我需要用@WebserviceTest注释我的测试。它是如何工作的?

Thanks a lot

我终于找到了解决办法。你必须加上

@Retention(RetentionPolicy.RUNTIME)

到注释