Codeception skipps test method even if depend-upon test was passed

1.1k Views Asked by At

I looked into manual here: http://codeception.com/docs/07-AdvancedUsage and there is ability to set @depens annotation for method.

class InvoiceStatusCest
{
    public function testOne()
    {

    }

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

}

But for my surprise my testTwo() always skips, even if testOne() if empty or passed...

i see in console

Running InvoiceStatusCest.testOne - Ok
 - Skipped
3

There are 3 best solutions below

1
On

Codeception has some seriously finicking annotation

For instance this

/*
 * @depends testOne
 */

will NOT work but this

/**
 * @depends testOne
 */

will work

NOTE the single * versus the ** at the beginning.

Just spent 4 hours of my life discovering this...

0
On

In your version of codeception dependencies are not handles very well, but you can accomplish what you want using this annotation instead:

class InvoiceStatusCest
{
    public function testOne()
    {

    }

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

}
1
On

I had issues with making a test depend on another test in another Cest. Using the just name of the test from the other Cest in the @depends annotation worked for me:

class InvoiceCest
{
    public function testCreate()
    {

    }
}

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

    }
}