Can't run Scalatest with Gradle

前端 未结 5 436
醉梦人生
醉梦人生 2021-02-02 09:28
task scalaTest(dependsOn: testClasses) << {
    description = \'Runs Scalatest suite\'
    ant.taskdef(name: \'scalatest\',
            classname: \'org.scalatest.         


        
5条回答
  •  挽巷
    挽巷 (楼主)
    2021-02-02 09:37

    You can put the following in your build.gradle:

    task spec(dependsOn: ['testClasses'], type: JavaExec) {
      main = 'org.scalatest.tools.Runner'
      args = ['-R', 'build/classes/scala/test', '-o']
      classpath = sourceSets.test.runtimeClasspath
    }
    

    Note: The path my be different depending on the gradle version as pointed out in the comments by @MikeRylander. Before gradle 4 it used to be 'build/classes/test'.

    Then just run gradle spec to execute your tests. I named the task spec because there already is a test task. Dunno if you can override the default test task.

    You can look up the available options here.

提交回复
热议问题