How can I run only one test from a suite?

Tzook Bar Noy picture Tzook Bar Noy · Aug 1, 2014 · Viewed 41.2k times · Source

I have this test class below, and I want to run only one test from it, for example the "aboutPage". Any ideas how?

This is how I run only this file:

codecept run tests/acceptance/VisitorCest.php

But now I want to run only one test from the file.

<?php
use \AcceptanceTester;

class VisitorCest
{
    public function _before(){}
    public function _after(){}

    public function aboutPage(AcceptanceTester $I)
    {
        $I->wantTo('check about page');
    }

    public function contactPage(AcceptanceTester $I)
    { 
        $I->wantTo('check contact page');
    }
}

Answer

Tzook Bar Noy picture Tzook Bar Noy · Aug 2, 2014

You simply append a colon and the function name, like this:

codecept run tests/acceptance/VisitorCest.php:myTestName

or a shorter version:

codecept run acceptance VisitorCest:myTestName

(Notice the space between the suite-name and the file-name.)