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

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

问题描述

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



例如:

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

def'test B'...
}

我想'test A'在'test B'之前始终执行



这是因为我正在使用Geb和Spock进行一些功能测试,并且数据在测试之间不会回滚。 方案

您可以在spec上使用 @Stepwise 注解,并且spock会按照指定的顺序运行Spec的每个测试定义。查看这个例子


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

For example:

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

    def 'test B'...
}

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

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

解决方案

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天全站免登陆