Surefire没有接受Junit 4测试
问题说明
即使我尝试了另一篇文章中的所有建议,也无法让Maven Surefire执行我的JUnit 4测试.
I cannot get Maven Surefire to execute my JUnit 4 tests even after I tried all the advices from another post.
我的POM:
<project>
<modelVersion>4.0.0</modelVersion>
<groupId>maven-test</groupId>
<artifactId>maven-test</artifactId>
<version>0.0.1-SNAPSHOT</version>
<dependencies>
<dependency>
<groupId>org.junit</groupId>
<artifactId>com.springsource.org.junit</artifactId>
<version>4.4.0</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.5</source>
<target>1.5</target>
</configuration>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.5</version>
</plugin>
</plugins>
</build>
</project>
我的测试:
public class TestSimple {
public void testSurePass()
{
int x = 1;
Assert.assertEquals(1, x);
}
@Test
public void surePass()
{
int x = 1;
Assert.assertEquals(1, x);
}
}
Surefire接受了testSurePass,但从未看到过surePass.我试过了mvn -X:
Surefire picked up testSurePass, but never saw surePass. I tried mvn -X:
[INFO] [surefire:test {execution: default-test}]
[DEBUG] dummy:dummy:jar:1.0 (selected for null)
[DEBUG] org.apache.maven.surefire:surefire-booter:jar:2.5:runtime (selected for runtime)
[DEBUG] org.apache.maven.surefire:surefire-api:jar:2.5:runtime (selected for runtime)
[DEBUG] Adding to surefire booter test classpath: C:\Users\.m2\repository\org\apache\maven\surefire\surefire-booter\2.5\surefire-booter-2.5.jar
[DEBUG] Adding to surefire booter test classpath: C:\Users\.m2\repository\org\apache\maven\surefire\surefire-api\2.5\surefire-api-2.5.jar
[DEBUG] dummy:dummy:jar:1.0 (selected for null)
[DEBUG] Retrieving parent-POM: org.apache.maven.surefire:surefire-providers:pom:2.5 for project: null:surefire-junit:jar:null from the repository.
[DEBUG] Adding managed dependencies for unknown:surefire-junit
[DEBUG] org.apache.maven.surefire:surefire-api:jar:2.5
[DEBUG] org.apache.maven.surefire:surefire-booter:jar:2.5
[DEBUG] org.codehaus.plexus:plexus-utils:jar:1.5.9
[DEBUG] org.apache.maven.surefire:surefire-junit:jar:2.5:test (selected for test)
[DEBUG] junit:junit:jar:3.8.1:test (selected for test)
[DEBUG] org.apache.maven.surefire:surefire-api:jar:2.5:test (selected for test)
[DEBUG] Adding to surefire test classpath: C:\Users\.m2\repository\org\apache\maven\surefire\surefire-junit\2.5\surefire-junit-2.5.jar
[DEBUG] Adding to surefire test classpath: C:\Users\.m2\repository\junit\junit\3.8.1\junit-3.8.1.jar
[DEBUG] Adding to surefire test classpath: C:\Users\.m2\repository\org\apache\maven\surefire\surefire-api\2.5\surefire-api-2.5.jar
[DEBUG] Test Classpath :
[DEBUG] C:\Workspace\tests\maven-test\target\test-classes
[DEBUG] C:\Workspace\tests\maven-test\target\classes
[DEBUG] C:\Users\.m2\repository\org\junit\com.springsource.org.junit\4.4.0\com.springsource.org.junit-4.4.0.jar
[DEBUG] Setting system property [user.dir]=[C:\Workspace\tests\maven-test]
[DEBUG] Setting system property [localRepository]=[C:\Users\.m2\repository]
[DEBUG] Setting system property [basedir]=[C:\Workspace\tests\maven-test]
Surefire 2.5自动将junit-3.8.1添加到其测试类路径.尽管还添加了junit-4.4.0(不是surefire测试类路径,而是Test Classpath),但junit-3.8.1似乎优先.根据 http:,Maven的surefire-api项目具有对junit-3.8.1的依赖. //maven.apache.org/surefire/surefire-providers/dependencies.html .
Surefire 2.5 adds junit-3.8.1 to its test classpath automatically. Although junit-4.4.0 is also added (not to surefire test classpath, but Test Classpath), junit-3.8.1 seems to take precedence. Maven's surefire-api project has a dependency on junit-3.8.1 according to http://maven.apache.org/surefire/surefire-providers/dependencies.html.
我在这里缺少一些配置吗?
Am I missing some configuration here?
正确答案
Surefire有一个junit-version工件检测机制,您正在使用springsource打包的junit工件来欺骗它.您需要设置 junitartifactname参数 到org.junit:com.springsource.org.junit
Surefire has a junit-version artifact detection mechanim that is being fooled by you using the junit artifact packaged by springsource. You need to set the junitartifactname parameter to org.junit:com.springsource.org.junit
这篇好文章是转载于:学新通技术网
- 版权申明: 本站部分内容来自互联网,仅供学习及演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,请提供相关证据及您的身份证明,我们将在收到邮件后48小时内删除。
- 本站站名: 学新通技术网
- 本文地址: /reply/detail/tanhcakkha
-
YouTube API 不能在 iOS (iPhone/iPad) 工作,但在桌面浏览器工作正常?
it1352 07-30 -
iPhone,一张图像叠加到另一张图像上以创建要保存的新图像?(水印)
it1352 07-17 -
保持在后台运行的 iPhone 应用程序完全可操作
it1352 07-25 -
使用 iPhone 进行移动设备管理
it1352 07-23 -
在android同时打开手电筒和前置摄像头
it1352 09-28 -
扫描 NFC 标签时是否可以启动应用程序?
it1352 08-02 -
检查邮件是否发送成功
it1352 07-25 -
Android微调工具-删除当前选择
it1352 06-20 -
希伯来语的空格句子标记化错误
it1352 06-22 -
Android App 和三星 Galaxy S4 不兼容
it1352 07-20