6. Reusing Test Code
Reusing Test Code
Codeception uses modularity to create a comfortable testing environment for every test suite you write. Modules allow you to choose the actions and assertions that can be performed in tests.
What are Actors
All actions and assertions that can be performed by the Actor object in a class are defined in modules. It might look like Codeception limits you in testing, but that’s not true. You can extend the testing suite with your own actions and assertions, by writing them into a custom module, called a Helper. We will get back to this later in this chapter, but for now let’s look at the following test:
<?php $I = new AcceptanceTester($scenario); $I->amOnPage('/'); $I->see('Hello'); $I->seeInDatabase('users', ['id' => 1]); $I->seeFileFound('running.lock');
It can operate with different entities: the web page can be loaded with the PhpBrowser modul