如何执行仅匹配正则表达式的测试? [英] How to execute tests that match a regular expression only?

查看:27
本文介绍了如何执行仅匹配正则表达式的测试?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 sbt 0.10.1 中,我经常使用 test-only 来缩小我的测试数量.

In sbt 0.10.1, I frequently use test-only to narrow down the number of my tests.

sbt> test-only com.example.MySpec

但是,我想缩小范围,以便我只运行名称/描述与正则表达式匹配的测试.是否有一些语法可以实现这样的目标?

However, I want to narrow down such that I only run tests whose name/description matches a regular expression. Is there some syntax to achieve something like this?

sbt> test-only .*someRexExp.*

推荐答案

testOnly 不支持完整的正则表达式.但是,支持通配符.

Full regular expressions are not supported by testOnly. Wildcards are supported, however.

sbt> testOnly com.example.*Spec

此处仅对星号 * 进行特殊解释,而不对句点进行特殊解释.这将选择所有以 com.example. 开头并以 Spec 结尾的测试.

Only the asterisk * is interpreted specially here and not the periods. This will select all tests beginning with com.example. and ending with Spec.

或者只是所有测试Spec:

sbt> testOnly *Spec

testOnly 和其他测试信息记录在此处:http://www.scala-sbt.org/release/docs/Detailed-Topics/Testing

testOnly and other testing information is documented here: http://www.scala-sbt.org/release/docs/Detailed-Topics/Testing

这篇关于如何执行仅匹配正则表达式的测试?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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