phptestingskipcodeception

How to skip a Codeception cest test


I want to skip only one test in a codeception cest test.

Using Cept tests you can do $scenario->skip(); but does not work for Cest tests.

So I want to do something like this. Run the first test, but skip the second one.

Class MyTests{

   public funtion test1(){
    // My test steps
     }

   public function test2(){
     $scenario->skip("Work in progress");
     }
}

Thank you in advance.


Solution

  • the method you are looking for is called "incomplete".

    $scenario->incomplete('your message, why skipping');

    If you want to use Scenarios in Cest files, you can get it with the second parameter of your test method:

    class yourCest 
    {
        public function yourTest(WebGuy $I, $scenario) 
        {
            $scenario->incomplete('your message');
        }
    }
    

    Or you can use $scenario->skip('your message')

    class yourCest 
    {
        public function yourTest(WebGuy $I, $scenario) 
        {
            $scenario->skip('your message');
        }
    }
    

    Edit:

    As already mentioned, the WebGuy is outdated and the annotations @skip or @incomplete are the way you should skip your tests in Cest files.

    class yourCest 
    {
    
        /**
         * @skip Skip message
         */
        public function yourTest(AcceptanceTester $I) 
        {
            $I->shouldTestSomething();
        }
    }