1

我在这里查看了手册:http: //codeception.com/docs/07-AdvancedUsage 并且可以为方法设置@depens 注释。

class InvoiceStatusCest
{
    public function testOne()
    {

    }

    /**
     * @depends testOne
     */
    public function testTwo()
    {
    }

}

但令我惊讶的是,我的 testTwo()总是跳过,即使 testOne() 如果为空或通过...

我在控制台中看到

Running InvoiceStatusCest.testOne - Ok
 - Skipped
4

3 回答 3

3

我在使测试依赖于另一个 Cest 中的另一个测试时遇到了问题。@depends在注释中使用来自另一个 Cest 的测试名称对我有用:

class InvoiceCest
{
    public function testCreate()
    {

    }
}

class InvoiceStatusCest
{
   /**
     * @depends testCreate
     */
    public function testChangeInvoiceStatus()
    {

    }
}
于 2016-04-09T17:19:37.393 回答
2

Codeception 有一些严重修饰的注释

例如这个

/*
 * @depends testOne
 */

不会工作,但这个

/**
 * @depends testOne
 */

将工作

注意开头的单个 * 与 **。

只是花了我生命中的 4 个小时才发现这个......

于 2014-12-16T23:54:26.423 回答
2

在您的代码接收版本中,依赖项处理得不是很好,但是您可以使用此注释来完成您想要的操作:

class InvoiceStatusCest
{
    public function testOne()
    {

    }

    /**
     * @depends Codeception\TestCase\Cest::testOne
     */
    public function testTwo()
    {
    }

}
于 2014-09-18T14:46:50.943 回答