如何在maven的scalatest中运行单个测试

jav*_*dba 17 scala maven scalatest

我还没有找到有关如何执行此操作的任何文档.对于JUnit,等效的是:

mvn -Dtest=org.apache.spark.streaming.InputStreamSuite test
Run Code Online (Sandbox Code Playgroud)

小智 21

我从这里找到了答案并且有效:( https://groups.google.com/forum/#!topic/scalatest-users/Rr0gy61dg-0)

运行测试'待定测试' HelloSuite,以及所有测试HelloWordSpec:

 mvn test -Dsuites='org.example.
HelloSuite @a pending test, org.example.HelloWordSpec' 
Run Code Online (Sandbox Code Playgroud)
  • 运行HelloSuite包含的所有测试'hello':

    mvn test -Dsuites='org.example.HelloSuite hello'

有关详细信息,请访问:http://scalatest.org/user_guide/using_the_scalatest_maven_plugin

  • 简而言之,`mvn test -Dsuites ="some.package.SpecsClass"` (3认同)

jav*_*dba 17

找到答案:是的

-DwildcardSuites
Run Code Online (Sandbox Code Playgroud)

所以这是示例命令行:

mvn -pl streaming -DwildcardSuites=org.apache.spark.streaming.InputStreamSuite test
Run Code Online (Sandbox Code Playgroud)

更新 较新版本的scalatest使用

 -Dsuites
Run Code Online (Sandbox Code Playgroud)

所以语法是:

mvn -pl streaming -Dsuites=org.apache.spark.streaming.InputStreamSuite test
Run Code Online (Sandbox Code Playgroud)


Ste*_*ran 15

请注意,如果你在同一模块中进行了一些Java测试,那么就像火花一样,你需要将它们关闭 - 你可以通过告诉surefire来运行不存在的测试

这是我刚刚运行的测试

mvn test -Dtest=moo -DwildcardSuites=org.apache.spark.deploy.yarn.ClientSuite
Run Code Online (Sandbox Code Playgroud)

跳过java测试,只运行scala测试.

scalatest似乎没有做的一件事是让你在套件中运行一个单独的测试,就像maven surefire那样.如果你在一个大套房中有一个失败的测试,那就不理想了.

[ 更正2016-08-22:看起来你可以按名称要求特定的套房; 看下面的其他答案.很高兴错了].