Running Scala test with gradle Scala plugin

Using the latest version of gradle (2.10) with Scala Plugin enabled , I am trying to run the tests located at src/test/scala.

But there are no tasks to run them:

$ ./gradlew tasks
....
Verification tasks
------------------
check - Runs all checks.
test - Runs the unit tests.

None of these two tasks will complete my Scala tests. Only those tests that are run are run at src/test/java. My Scala test tests use Specs2using the following dependencies for test ( build.gradle):

apply plugin: 'scala'

dependencies {
    testCompile(
        'org.specs2:specs2-core_2.12.0-M3:3.6.6-scalaz-7.2.0'
    )
}

I checked: tests are collected when used ./gradlew compileTestScala.

What needs to be done to complete these tests?

+4
source share
1 answer

Well, that was easy:

import org.specs2.runner.JUnitRunner
@RunWith(classOf[JUnitRunner])
class FooSpec extends Specification {
  // test code
  ...
}
+3
source

Source: https://habr.com/ru/post/1624249/


All Articles