Gizzmo Gizzmo - 6 months ago 45
PHP Question

How do you run a codeception test from within a php script?

I do not want to run a codeception test from the CLI:

php <pathToCodeCeption>/codecept run


I want to run it inside a PHP script:

<?php

$codeCeptionRunner = /* What to do here*/;
$codeCeptionRunner->run();


Does anyone has an idea how to accomplish this task?

Answer

Start with this snippet:

<?php
require_once '/path/to/codeception/autoload.php';

$Codecept = new \Codeception\Codecept(array(
    'steps' => true,
    'verbosity' => 1,
    // some other options (see Codeception docs/sources)
 ));

 $Codecept->run('your_test_suit_name');

and then dig into Codeception sources. It is really clear and easy to understand.

Comments