May*_*y12 1 java junit4 mule maven maven-surefire-plugin
我不明白为什么 maven-surefire-plugin 不运行 jUnit4 测试。我的 pom 是(无法在此处添加它,因为“它看起来帖子主要是代码”):http://pastebin.com/Jj3iJZpY
当我执行mvn clean testcmd窗口时显示:
C:\Users\maya\git\services>mvn clean test
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building services 1.0.18
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-clean-plugin:2.5:clean (default-clean) @ services ---
[INFO] Deleting C:\Users\maya\git\services\target
[INFO]
[INFO] --- maven-mule-plugin:1.9:attach-test-resources (default-attach-test-resources) @ services ---
[INFO] attaching test resource C:\Users\maya\git\services\src\main\app
[INFO]
[INFO] --- build-helper-maven-plugin:1.7:add-resource (add-resource) @ services ---
[INFO]
[INFO] --- maven-resources-plugin:2.7:resources (default-resources) @ services ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 4 resources
[INFO] Copying 3 resources
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-mule-plugin:1.9:filter-resources (default-filter-resources) @ services ---
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:compile (default-compile) @ services ---
[INFO] Compiling 60 source files to C:\Users\maya\git\services\target\classes
[INFO]
[INFO] --- maven-resources-plugin:2.7:testResources (default-testResources) @ services ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 0 resource
[INFO] Copying 3 resources
[INFO]
[INFO] --- maven-compiler-plugin:2.3.2:testCompile (default-testCompile) @ services ---
[INFO] Compiling 1 source file to C:\Users\maya\git\services\target\test-classes
[INFO]
[INFO] --- maven-surefire-plugin:2.19:test (default-test) @ services ---
[INFO]
[INFO] --- maven-surefire-plugin:2.19:test (default) @ services ---
[INFO] Skipping execution of surefire because it has already been run for this configuration
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 8.554 s
[INFO] Finished at: 2015-12-11T15:48:05+03:00
[INFO] Final Memory: 48M/312M
[INFO] ------------------------------------------------------------------------
Run Code Online (Sandbox Code Playgroud)
测试类是:
package com.comp.utils.UtilsTest;
import static org.junit.Assert.assertTrue;
import org.apache.log4j.Logger;
import org.junit.Test;
public class UtilsTest {
private static final Logger LOG = Logger.getLogger(UtilsTest.class.getName());
@Test
public void testHasPersonSameProd() {
boolean hasSameProduct = false;
assertTrue("Should be True", hasSameProduct);
}
}
Run Code Online (Sandbox Code Playgroud)
为什么 maven-surefire-plugin:2.19 运行两次并且不想运行我的测试类?如何在我的情况下运行测试?谢谢。
给定您链接的 pom(实际上应该包含在问题中,因为链接将来可能会被破坏):
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.19</version>
<executions>
<execution>
<goals>
<goal>test</goal>
</goals>
</execution>
</executions>
<dependencies>
<dependency>
<groupId>org.apache.maven.surefire</groupId>
<artifactId>surefire-junit47</artifactId>
<version>2.19</version>
</dependency>
</dependencies>
<configuration>
<includes>
<include>UtilTest.java</include>
</includes>
</configuration>
</plugin>
Run Code Online (Sandbox Code Playgroud)
id元素,因此默认情况下它被称为default( maven-surefire-plugin:2.19:test (default))。此执行在 Surefire ( ) 的开箱即用 Maven 配置之后运行maven-surefire-plugin:2.19:test (default-test)。因此,您有两个执行(default和default-test)。删除executionsSurefire 插件配置部分,您将只有一次执行(default-test)。<include>UtilTest.java</include>配置指向该类UtilTest.java,而在您的问题中它被命名UtilsTest(注意附加的“s”)。src/test/java文件夹下,那么您不需要配置其包含,因为它也已经遵循 Surefire 的默认约定,"**/*Test.java".Skipping execution of surefire because it has already been run for this configuration) 是因为configurationSurefire 插件的元素位于任何executions元素之外,这意味着适用于所有插件执行,甚至是默认插件 ( default-test)。因此,您可能可以从 pom 中删除整个 Surefire 插件部分,并且问题应该得到解决。
| 归档时间: |
|
| 查看次数: |
4899 次 |
| 最近记录: |