仅从 sbt 运行特定的 Scalatest 测试 [英] Run just a specific scalatest test from sbt

查看:48
本文介绍了仅从 sbt 运行特定的 Scalatest 测试的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

sbttest-only 命令可用于运行在特定测试类中找到的测试.使用 JUnit 测试,您可以使用 test-only 在测试类上运行特定方法,例如test-only mypackage.MyTestClass.test1Equals1 只运行那个方法.

使用 scalatest 的更自由形式的测试语法,可能是通过计算它在内部使用的名称来引用特定测试,这样的事情是否可能?如果在 FreeSpec 中不可能(鉴于其性质,这很容易想象)有没有办法用更简单的测试方法来做到这一点,比如 FunSuite?

解决方案

对于一般的解决方案,我们需要等待 sbt#911,但显然 ScalaTest 2.1.3支持运行特定测试.Seth 说:

<块引用>

ScalaTest 2.1.3 现在支持:

test-only *MySuite -- -z foo

<块引用>

仅运行名称包含子字符串foo"的测试.对于精确匹配而不是子字符串,使用 -t 而不是 -z.

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?

解决方案

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.

这篇关于仅从 sbt 运行特定的 Scalatest 测试的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆