Run just a specific scalatest test from sbt

不羁的心 提交于 2019-12-04 17:10:12

问题


sbt's test-only command can be used to run the tests found in a specific test class. With JUnit tests you can use test-only to run specific methods on a test class e.g. test-only mypackage.MyTestClass.test1Equals1 to run just that method.

Is such a thing possible with scalatest's more free-form test syntax, presumably by working out the name it uses internally to reference a specific test? If it isn't possible in FreeSpec (which is easy to imagine given its nature) is there a way to do it with a simpler testing approach like FunSuite?


回答1:


For a general solution we need to wait for sbt#911, but apparently ScalaTest 2.1.3 has a support for running a specific test. Seth says:

This is now supported in ScalaTest 2.1.3 with:

test-only *MySuite -- -z foo

to run only the tests whose name includes the substring "foo". For exact match rather than substring, use -t instead of -z.




回答2:


To run a test:

sbt test-only com.path.to.UnitTestSpec

To run a particular integration test:

sbt it:test-only com.path.to.IntegrationTestSpec



来源:https://stackoverflow.com/questions/22205484/run-just-a-specific-scalatest-test-from-sbt

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!