我想运行名称以ResourceTest.java结尾的测试类,因此我在执行后定义了它们。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<configuration>
<excludes>
<exclude>**/*.java</exclude>
</excludes>
</configuration>
<version>2.12.2</version>
<executions>
<execution>
<id>resource-tests</id>
<phase>resource-tests</phase>
<goals>
<goal>resource-tests</goal>
</goals>
<configuration>
<includes>**/*ResourceTest.java</includes>
<!-- <exludes>**/*.java</exludes> -->
</configuration>
</execution>
</executions>
</plugin>
但是我不确定如何运行它,已经搜索了很多东西,但缺少了一些东西。
我尝试了surefire:test,它跳过了上述配置中定义的所有测试用例。因此,我尝试了surefire:resource-tests
,maven表示没有定义任何目标。
通过传递这些参数,我正在使用eclipse运行我的Maven构建。如何通过执行ID运行?
当我使用pom中定义的多重执行时,如何在使用surefire:test时如何选择特定执行?
我想念什么?任何帮助,将不胜感激。
java大神给出的解决方案
您当前的配置存在一些问题:
您将强制在maven-surefire-plugin
阶段执行resource-tests
,但是在此阶段does not exist。您应该删除该声明以保留默认的插件绑定阶段,即test
。
您正在调用目标resource-tests
,但是maven-surefire-plugin
does not define such a goal。<includes>
元素定义不正确。下面应该有一个<include>
标记。
您将从插件配置中排除所有Java文件,因此将不运行任何测试
插件的配置不应在每个<configuration>
的<executions>
元素下进行。
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.2</version>
<configuration>
<includes>
<include>**/*ResourceTest.java</include>
</includes>
</configuration>
</plugin>
当您有多个执行并且想要“选择”其中一个执行时,可以使用一个配置文件:
<profiles>
<profile>
<id>resource-tests</id>
<properties>
<test-classes>**/*ResourceTest.java</test-classes>
</properties>
</profile>
<profile>
<id>task-tests</id>
<properties>
<test-classes>**/*TaskTest.java</test-classes>
</properties>
</profile>
</profiles>
具有以下插件配置:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.12.2</version>
<configuration>
<includes>
<include>${test-classes}</include>
</includes>
</configuration>
</plugin>
通过这样的配置:
当您运行mvn clean test -Presource-tests
时,将仅测试与**/*ResourceTest.java
匹配的类
当您运行mvn clean test -Ptask-tests
时,将仅测试与**/*TaskTest.java
匹配的类
我有以下JSP:<%@ page import="foo.*" %> <html> <body> The page count is: <%=Counter.getCount()%> </body> </html> 我在包Counter中有一个foo类,该类存储在: …
DataSourceTransactionManager和JndiObjectFactoryBean和JdbcTemplate的用途是什么? - java以下的用途是什么:org.springframework.jdbc.core.JdbcTemplate org.springframework.jdbc.datasource.DataSourceTransactionManager org.springframework.jndi.JndiObjectFactoryBean <tx:annotatio…
Map <String,String>,如何同时打印“键字符串”和“值字符串” [重复] - javaThis question already has answers here: How do I efficiently iterate over each entry in a Java Map? (43个答案) 4年前关闭。 我是Java的新手,正在尝试学习Maps的概念。我想出了下面的代码。但是,我想同时打印出“键字符串”和“值字符串”。Process…
java:继承 - java有哪些替代继承的方法? java大神给出的解决方案 有效的Java:偏重于继承而不是继承。 (这实际上也来自“四人帮”)。他提出的理由是,如果扩展类未明确设计为继承,则继承会引起很多不正常的副作用。例如,对super.someMethod()的任何调用都可以引导您通过未知代码的意外路径。取而代之的是,持有对本来应该扩展的类的引用,然后委托给它。这是与Eric…
T是此代码中的类还是接口? - javaWhat is <? super T> syntax?我正在阅读此答案,这使我消除了一些疑问,但我不明白这一行中的一件事:T extends Comparable< ? super T>该帖子答复中的每个人都解释说T实现了Comparable<T or T's superclass>;但是有书面的扩展,所以T是C…