FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

GitHub Viewer

--- layout: doc title: Reusing Test Code - Codeception Docs ---
💡 You are reading docs for latest Codeception 5. Read for 4.x
# 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->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 module, the database assertion uses the Db module, and the file state can be checked with the Filesystem module. Modules are attached to Actor classes in the suite config. For example, in `tests/Acceptance.suite.yml` we should see: ```yaml actor: AcceptanceTester modules: enabled: - PhpBrowser: url: http://localhost - Db - Filesystem ``` The AcceptanceTester class has its methods defined in modules. Let's see what's inside the `AcceptanceTester` class, which is located inside the `tests/Support` directory: ```php

Back | FazBrowse Home | New Git URL