确定 Spock 测试的执行顺序 [英] Determine order of execution of Spock tests

查看:34
本文介绍了确定 Spock 测试的执行顺序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有没有办法设置在 Spock 规范中执行测试的顺序?

Is there a way to set the order in which tests are executed within an Spock Specification?

例如:

class MySpec extends IntegrationSpec {
    def 'test A'...

    def 'test B'...
}

我希望测试 A"总是在测试 B"之前执行

I want 'test A' to be execute always before 'test B'

这是因为我正在用 Geb 和 Spock 进行一些功能测试,并且数据在测试之间没有回滚.

This is because I'm doing some functional tests with Geb and Spock and data is not rolled back between tests.

推荐答案

您可以在规范上使用 @Stepwise 注释,并且 spock 将按照它们的顺序运行 Spec 的每个测试定义指定的.看看这个例子.

You can use @Stepwise annotation on a spec and spock will run each of the test definitions of the Spec in the order they are specified. Look at this example.

这篇关于确定 Spock 测试的执行顺序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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