本文介绍了无法使用Gradle运行Scalatest的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
task scalaTest(dependsOn: testClasses) << {
description = 'Runs Scalatest suite'
ant.taskdef(name: 'scalatest',
classname: 'org.scalatest.tools.ScalaTestAntTask',
classpath: sourceSets.test.runtimeClasspath.asPath
)
ant.scalatest(runpath: sourceSets.test.output.classesDir,
haltonfailure: 'true', fork: 'false') {
reporter(type: 'stdout')
}
}
我运行gradle scalaTest,我得到:
* What went wrong: Execution failed for task ':scalaTest'. > java.lang.NoClassDefFoundError: scala/reflect/ClassManifest$我正在使用Scala 2.10.2和Gradle 1.7
I am using Scala 2.10.2 and Gradle 1.7
dependencies { compile 'org.scala-lang:scala-library:2.10.2' testCompile 'org.scalatest:scalatest:1.3' testCompile 'org.scalamock:scalamock_2.10:3.0.1' }怎么了?
推荐答案我不知道如何解决这个问题,但是我可以为您提供解决方法.用@RunWith(classOf[JUnitRunner])注释测试类,如下所示:
I do not know how to solve this one, but I can offer you a workaround. Annotate your test classes with @RunWith(classOf[JUnitRunner]), like this:
import org.scalatest.junit.JUnitRunner import org.junit.runner.RunWith @RunWith(classOf[JUnitRunner]) class MyTest extends FunSpec{ },然后gradle test应该可以工作.
我的依赖项:
compile "org.scala-lang:scala-library:2.10.1" testCompile "org.scalatest:scalatest_2.10:1.9.1"更多推荐
无法使用Gradle运行Scalatest
发布评论