Is there a way to control the order of tests in Codeception?

I just started using Codeception after several years of writing unit tests in regular PHPUnit . One thing that overhears me is that I cannot find a way to control the order in which the tests run.

In a clean old PHPUnit I build the test structure manually as follows:

 $suite = new PHPUnit_Framework_TestSuite(); $suite->addTest('MyFirstTest'); $suite->addTest('MySecondTest'); 

and the test will be called in the order in which they were added to the set. Codeception , on the other hand, seems to iterate through the directories and run every test that it can find.

I would like to be able to control the order of tests at two levels:

  • The order in which different types of tests are called (for example, I would like to run unit tests before acceptance tests )
  • I would like to control the order of tests called in a particular type of test (similar to PHPUnit builds suites)

Ad. 2: Let's say I have two tests in the acceptance directory:

 AbcCept.php WebGuy.php XyzCept.php 

I want to be able to run XyzCept.php before AbcCept.php . Is it possible?

And to anticipate picky comments: yes, I know that tests should be able to work in any order and not depend on each other, but this is not what I ask.

+7
php phpunit codeception
source share
1 answer

Files are sorted by name (I assume we are talking about files from the same directory). In other words, if you need to run the XyzCept.php test before AbcCept.php , you rename XyzCept.php to, say, AazCept.php .

+7
source share

All Articles