Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Can't run Scalatest with Gradle

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??

like image 789
Joshua MN Avatar asked Sep 16 '13 08:09

Joshua MN


People also ask

Does gradle work with Scala?

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.


1 Answers

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" 
like image 171
rarry Avatar answered Oct 19 '22 16:10

rarry