Generating Tests


In this video we follow the third step of the Codeception quick start which is to generate our first test files.

However, deviating slightly from the Codeception quick start, we are going to go ahead and generate the four different types of test that Codeception provides for our use. These are:

  • Cept (ac-Cept-ance test)
  • Cest (a combination of Acceptance and Test)
  • PHPUnit
  • Test (Codeception's enhanced PHPUnit tests)

The syntax we will need is:

php vendor/codeception/codeception/codecept generate:cept acceptance MyFirstAcceptanceTest

php vendor/codeception/codeception/codecept generate:cest functional MyFirstFunctionalTest

php vendor/codeception/codeception/codecept generate:unit unit MyFirstUnitTest

php vendor/codeception/codeception/codecept generate:test unit MyFirstCodeceptionEnhancedPHPUnitTest

You can, of course, use the shorter syntax here.

There's lots more going on here including sub directories, some real world good practices to follow, and more.

Enjoy!

Code For This Course

Get the code for this course.

Code For This Video

Get the code for this video.

Episodes