用maven install的时候 显示 test failure?
为什么我单独跑junit的单元测试能通过,
但如果用maven install的时候 显示 test failure? maven 新手 多多指教~
-------------------------------------------------------
T E S T S
-------------------------------------------------------
Running com.jit.touchscreen3.repository.DepRepositoryTest
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0, Time elapsed: 0.016 sec <<< FAILURE!
Results :
Failed tests:
com.jit.touchscreen3.repository.DepRepositoryTest.testDep()
Tests run: 1, Failures: 1, Errors: 0, Skipped: 0
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 2.468s
[INFO] Finished at: Wed Jan 28 10:54:00 CST 2015
[INFO] Final Memory: 4M/8M
[INFO] ------------------------------------------------------------------------
[ERROR] Failed to execute goal org.apache.maven.plugins:maven-surefire-plugin:2.7.1:test (default-test) on project touchscreen3: There are test failures.
[ERROR]
[ERROR] Please refer to F:trunkOTAtouchscreen3targetsurefire-reports for the individual test results.
[ERROR] -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
工程目录结构:
下面是测试类代码。总觉得好像maven构建的时候 没找到我测试类中的配置文件~
package com.jit.touchscreen3.repository; import static org.junit.Assert.*; import java.util.List; import javax.annotation.Resource; import org.junit.Test; import org.junit.runner.RunWith; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.SpringJUnit4ClassRunner; import com.jit.touchscreen3.entity.Department; /* * @author junming_ren * @version 2015-1-27 上午10:26:47 */ @RunWith(SpringJUnit4ClassRunner.class) @ContextConfiguration(locations = "classpath:applicationContext-test.xml") public class DepRepositoryTest { @Resource private DepRepository repository; @Test public void testDep(){ List<Department> list = repository.findAll(); assertNotNull(list); } }
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(5)
晕。。 你们都是这么去掉的? 感觉这不是正确的使用方法啊~
@渔樵耕读 我没细看你那个方法 ,这是临时解决 方案
你可以 把 测试的去掉, mvn clean install -Dmaven.test.skip=true
额。。我知道是单位测试没通过~ 原因应该是引用的applicationContext配置文件路径不对 但是不知道咋配置test的applicationContext