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') } }
I run gradle scalaTest
and I get:
* What went wrong: Execution failed for task ':scalaTest'. > java.lang.NoClassDefFoundError: scala/reflect/ClassManifest$
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' }
What's wrong??
Gradle supports version 1.6. 0 of Zinc and above. The Zinc compiler itself needs a compatible version of scala-library that may be different from the version required by your application. Gradle takes care of specifying a compatible version of scala-library for you.
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{ }
and then, gradle test
should work.
Edit:
My dependencies:
compile "org.scala-lang:scala-library:2.10.1" testCompile "org.scalatest:scalatest_2.10:1.9.1"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With