对于导入的gradle项目,无法从IDEA 13.0 IDE运行Junit测试

时间:2013-12-22 22:41:43

标签: java android junit intellij-idea gradle

我有一个包含一些java模块和一个android模块的Gradle项目。每件事看起来都很好,项目在Android设备上构建和部署。 但是,我有一个重大问题。因为我正在使用IDEA进行TDD。我必须像往常一样从IDE运行单元测试,但我总是收到一条错误消息:找不到类:“[full.class.name]”

- >使用dynamic.classpath = true:生成的命令为:

C:\Program Files\Java\jdk1.7.0_17\bin\java" -Didea.launcher.port=7533 "-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA 13.0\bin" -classpath "C:\Program Files (x86)\JetBrains\IntelliJ IDEA 13.0\lib\idea_rt.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA 13.0\lib\util.jar" -Dfile.encoding=UTF-8 com.intellij.rt.execution.CommandLineWrapper C:\Users\[UserName]\AppData\Local\Temp\classpath9127004204172317095.tmp com.intellij.rt.execution.application.AppMain com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 [full.class.name]

Class not found: "[full.class.name]"
Process finished with exit code 1

- >使用dynamic.classpath = false:命令为:

"C:\Program Files\Java\jdk1.7.0_17\bin\java" -Didea.launcher.port=7532 "-Didea.launcher.bin.path=C:\Program Files (x86)\JetBrains\IntelliJ IDEA 13.0\bin" -Dfile.encoding=UTF-8 -classpath "C:\Program Files (x86)\JetBrains\IntelliJ IDEA 13.0\lib\idea_rt.jar;C:\Program Files (x86)\JetBrains\IntelliJ IDEA 13.0\plugins\junit\lib\junit-rt.jar;C:\Program Files\Java\jdk1.7.0_17\jre\lib\charsets.jar;C:\Program Files\Java\jdk1.7.0_17\jre\lib\deploy.jar;C:\Program Files\Java\jdk1.7.0_17\jre\lib\javaws.jar;C:\Program Files\Java\jdk1.7.0_17\jre\lib\jce.jar;C:\Program Files\Java\jdk1.7.0_17\jre\lib\jfr.jar;C:\Program Files\Java\jdk1.7.0_17\jre\lib\jfxrt.jar;C:\Program Files\Java\jdk1.7.0_17\jre\lib\jsse.jar;C:\Program Files\Java\jdk1.7.0_17\jre\lib\management-agent.jar;C:\Program Files\Java\jdk1.7.0_17\jre\lib\plugin.jar;C:\Program Files\Java\jdk1.7.0_17\jre\lib\resources.jar;C:\Program Files\Java\jdk1.7.0_17\jre\lib\rt.jar;C:\Program Files\Java\jdk1.7.0_17\jre\lib\ext\access-bridge-64.jar;C:\Program Files\Java\jdk1.7.0_17\jre\lib\ext\dnsns.jar;C:\Program Files\Java\jdk1.7.0_17\jre\lib\ext\jaccess.jar;C:\Program Files\Java\jdk1.7.0_17\jre\lib\ext\localedata.jar;C:\Program Files\Java\jdk1.7.0_17\jre\lib\ext\sunec.jar;C:\Program Files\Java\jdk1.7.0_17\jre\lib\ext\sunjce_provider.jar;C:\Program Files\Java\jdk1.7.0_17\jre\lib\ext\sunmscapi.jar;C:\Program Files\Java\jdk1.7.0_17\jre\lib\ext\zipfs.jar;C:\Users\[UserName]\.gradle\caches\artifacts-26\filestore\junit\junit\4.11\jar\4e031bb61df09069aeb2bffb4019e7a5034a4ee0\junit-4.11.jar;C:\Users\[UserName]\.gradle\caches\artifacts-26\filestore\org.hamcrest\hamcrest-core\1.3\jar\42a25dc3219429f0e5d060061f71acb49bf010a0\hamcrest-core-1.3.jar;C:\Users\[UserName]\.gradle\caches\artifacts-26\filestore\org.apache.commons\commons-lang3\3.1\jar\905075e6c80f206bbe6cf1e809d2caa69f420c76\commons-lang3-3.1.jar;C:\Users\[UserName]\.gradle\caches\artifacts-26\filestore\javax.inject\javax.inject\1\jar\6975da39a7040257bd51d21a231b76c915872d38\javax.inject-1.jar;C:\Users\[UserName]\.gradle\caches\artifacts-26\filestore\org.objenesis\objenesis\1.0\jar\9b473564e792c2bdf1449da1f0b1b5bff9805704\objenesis-1.0.jar;C:\Users\[UserName]\.gradle\caches\artifacts-26\filestore\org.mockito\mockito-core\1.9.5\jar\c3264abeea62c4d2f367e21484fbb40c7e256393\mockito-core-1.9.5.jar" com.intellij.rt.execution.application.AppMain com.intellij.rt.execution.junit.JUnitStarter -ideVersion5 [full.class.name]

Class not found: "[full.class.name]"
Process finished with exit code 1

3 个答案:

答案 0 :(得分:2)

Jetbrains支持团队向我确认这是一个主要错误,应该在下一个版本13.0.1中解决。发布日期尚未定义。

问题是由Android-Gradle项目引起的。

答案 1 :(得分:2)

在从IDEA运行测试之前,只需通过运行" clean"来调用清理。来自Gradle的任务。希望这会有所帮助。

答案 2 :(得分:1)

当我没有将Java代码放在预期的默认位置时,我得到了同样的错误:src / main / java和src / test / java。一旦我解决了这个问题,我就可以从IDEA或命令行运行测试。