使用gradle Scala插件运行Scala测试
使用最新版本的gradle(2.10)并启用,我试图执行位于使用gradle Scala插件运行Scala测试,gradle,gradle-scala,Gradle,Gradle Scala,使用最新版本的gradle(2.10)并启用,我试图执行位于src/test/scala的测试 但似乎没有任务运行这些: $ ./gradlew tasks .... Verification tasks ------------------ check - Runs all checks. test - Runs the unit tests. 这两个任务都不会执行我的Scala测试。执行的测试只有src/test/java中的测试。My Scala测试使用Specs2使用以下测试依赖项(b
src/test/scala
的测试
但似乎没有任务运行这些:
$ ./gradlew tasks
....
Verification tasks
------------------
check - Runs all checks.
test - Runs the unit tests.
这两个任务都不会执行我的Scala测试。执行的测试只有src/test/java
中的测试。My Scala测试使用Specs2
使用以下测试依赖项(build.gradle
):
我检查过:测试是在使用/gradlew compileTestScala
时编译的
执行这些测试需要做些什么?好的,很简单:
import org.specs2.runner.JUnitRunner
@RunWith(classOf[JUnitRunner])
class FooSpec extends Specification {
// test code
...
}
另一个解决方案:使用gradle插件com.github.maiflai.scalatest 对于这种解决方案,Scala测试将使用org.scalatest.tools.Runner运行
dependencies {
implementation 'org.scala-lang:scala-library:2.13.3'
testImplementation 'org.scalatest:scalatest_2.13:3.2.0'
testImplementation 'junit:junit:4.13'
testImplementation 'com.vladsch.flexmark:flexmark-all:0.35.10'
}
flexmark的版本很重要,因为scalatest框架在其代码中硬编码了这样的版本
dependencies {
implementation 'org.scala-lang:scala-library:2.13.3'
testImplementation 'org.scalatest:scalatest_2.13:3.2.0'
testImplementation 'junit:junit:4.13'
testImplementation 'com.vladsch.flexmark:flexmark-all:0.35.10'
}