要从Maven pom.xml执行单个Test,我们可以从maven surefire插件执行它。
http://maven.apache.org/surefire/maven-surefire-plugin/examples/inclusion-exclusion.html
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.22.0</version>
<configuration>
<includes>
<include>App.java</include>
</includes>
</configuration>
</plugin>
</plugins>
</build>
字符串
但是,它不工作,因为现在.有些东西是失踪申报?我记得,前几个月一旦我执行它,它的工作.
控制台:
[INFO] Scanning for projects...
[INFO]
[INFO] --------------< mavenSampleProject01:mavenSampleProjects >--------------
[INFO] Building mavenSampleProjects 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-resources-plugin:2.6:resources (default-resources) @ mavenSampleProjects ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\Desktop-pc\eclipse-workspace\mavenSampleProjects\src\main\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:compile (default-compile) @ mavenSampleProjects ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-resources-plugin:2.6:testResources (default-testResources) @ mavenSampleProjects ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory C:\Users\Desktop-pc\eclipse-workspace\mavenSampleProjects\src\test\resources
[INFO]
[INFO] --- maven-compiler-plugin:3.1:testCompile (default-testCompile) @ mavenSampleProjects ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- maven-surefire-plugin:2.22.0:test (default-test) @ mavenSampleProjects ---
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 1.371 s
[INFO] Finished at: 2018-10-02T11:58:27+05:30
[INFO] ------------------------------------------------------------------------
型
3条答案
按热度按时间1cklez4t1#
您需要提供完整的限定类名才能通过surefire plugin. https://maven.apache.org/surefire/maven-surefire-plugin/examples/inclusion-exclusion.html包含它
或者,您可以使用正则表达式,如“**/* App.java”
mec1mxoz2#
添加以下插件到您的POM文件。
字符串
6rqinv9w3#
我发现,Maven test只能从src/test/java包中运行
不考虑从src/main/java运行
如果需要考虑src/main/java,我们必须添加
<testSourceDirectory>
元素字符串