junit:找不到测试类 [英] junit: could not find test class

查看:748
本文介绍了junit:找不到测试类的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经在这里和其他地方查看了重复的问题,包括JUnit FAQ(http://junit.sourceforge.net/doc/faq/faq.htm#running_1).

I've looked at the duplicate questions here and elsewhere, including the JUnit FAQ (http://junit.sourceforge.net/doc/faq/faq.htm#running_1).

junit-4.10.jar位于/Library/Java/Extensions中,该文件自动位于类路径上.

junit-4.10.jar is at /Library/Java/Extensions which is automatically on the classpath.

我的测试类在我的工作目录中编译.它不是任何程序包的一部分.但是,这些都不起作用:

My test class is compiled in my working directory. It is not part of any package. However, none of these work:

java org.junit.runner.JUnitCore TestBoard
java -cp . org.junit.runner.JUnitCore TestBoard

两次返回:

JUnit version 4.10
Could not find class: TestBoard

Time: 0.001

OK (0 tests)

推荐答案

最近,我的Junits测试也遇到了类似的问题.运行测试(在我的案例中为"mvn测试")引起了几种类型的误导性执行. 事实证明,我在项目中使用的是jdk 1.6.当我切换到jdk 1.7时,一切都结束了.

Recent I had similar problem with my junits tests. Running tests ('mvn test' in my case) caused few types of misleading execptions. As it turned out i was using jdk 1.6 in my project. When i've switched to jdk 1.7 everything ended.

这篇关于junit:找不到测试类的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆