mercredi 21 octobre 2015

Codeception - Depend on a test within a parent class

Is it possible to have Cest files that extend a parent class and make use of a common test "login" that other tests depend on using the @depends

So my Cest file looks similar to the one found in this post which explains how to login and re-use the cookie in another test - http://ift.tt/1LL0XFg

I've got this common class but the test in the child class doesn't run and outputs...This test depends on 'commonCest::login' to pass.

<?php

class commonCest {

    const COOKIE_NAME = 'PHPSESSID';

    protected $cookie;

    /**
     * Most tests will need to depend on this function as it logs the user in and stores the session cookie, use the
     * "@depends" phpdoc comment
     *
     * The cookie in then  re-used by calling the following in tests:
     *
     *     $I->setCookie(self::COOKIE_NAME, $this->cookie);
     *
     * @param \AcceptanceTester $I
     */
    public function login(AcceptanceTester $I) {
        $I->wantTo('Login');
        $I->amOnPage('/login');
        $I->fillField(array('name' => 'username'), 'aaaaaa');
        $I->fillField(array('name' => 'password'), 'abcdef');
        $I->click('.form-actions button');
        $I->seeElement('.username');
        $this->cookie = $I->grabCookie(self::COOKIE_NAME);
    }
}


<?php
use \AcceptanceTester;

class rolesCest extends commonCest 
{

    /**
     * @depends login (This doesn't work)
     * @depends commonCest:login (This doesn't work)
     * @depends commonCest::login (This doesn't work)
     */
    public function listUsers(AcceptanceTester $I)
    {
        // tests
    }

?>

Aucun commentaire:

Enregistrer un commentaire