From 29152cd832044515ad27e365e1477674e56c45e8 Mon Sep 17 00:00:00 2001 From: W0rma Date: Sun, 22 Nov 2026 19:18:50 +0100 Subject: [PATCH 01/11] Update Selenium setup in acceptance testing guide --- docs/AcceptanceTests.md | 34 +++++++++++++++++++--------------- 1 file changed, 19 insertions(+), 15 deletions(-) diff --git a/docs/AcceptanceTests.md b/docs/AcceptanceTests.md index 7c73cb36d..eba0f1e44 100644 --- a/docs/AcceptanceTests.md +++ b/docs/AcceptanceTests.md @@ -361,33 +361,37 @@ In the next section, we will overview the most popular solutions. ### Local Setup -### Selenium Server +Codeception can control browsers either through Selenium Server or directly through a browser driver +(ChromeDriver for Chrome, GeckoDriver for Firefox). -[Selenium](https://www.selenium.dev) is required to launch and control browsers from Codeception. -Selenium Server is required to be installed and started before running tests. +#### Selenium Server -The fastest way of getting Selenium is using [selenium-standalone](https://www.npmjs.com/package/selenium-standalone) NodeJS Package. -It automatically installs Selenium and all required dependencies and starts server. It requires **NodeJS and Java** to be installed. +[Selenium](https://www.selenium.dev) Server starts browser sessions and passes commands from Codeception to them. +It requires **Java** to be installed. [Download](https://www.selenium.dev/downloads/) the latest Selenium Server jar +and launch it in standalone mode in a separate terminal: -``` -npm install selenium-standalone -g -selenium-standalone install +```bash +java -jar selenium-server-.jar standalone ``` -Launch this command in a separate terminal: +There is no need to install ChromeDriver or GeckoDriver separately: +[Selenium Manager](https://www.selenium.dev/documentation/selenium_manager/) downloads the matching driver for the installed browser automatically. -``` -selenium-standalone start +Alternatively, run Selenium Server with a browser inside Docker using the [official image](https://github.com/SeleniumHQ/docker-selenium): + +```bash +docker run --net=host --shm-size 2g selenium/standalone-chrome ``` -![](https://raw.githubusercontent.com/webdriverio/selenium-standalone/HEAD/screencast.gif) +> The [RunProcess](https://codeception.com/extensions#RunProcess) extension can start and stop Selenium automatically. Now, you are ready to run WebDriver tests using Codeception. -> Alternatively, Selenium Server can be installed manually. [Download it](https://www.selenium.dev/downloads/) from the official site and launch a server with Java: `java -jar selenium-server-....jar`. In this case ChromeDriver and GeckoDriver must be installed separately. +#### ChromeDriver or GeckoDriver -* For more information refer to [Installation Instructions](https://codeception.com/docs/modules/WebDriver#Selenium-Recommended) -* Enable [RunProcess](https://codeception.com/extensions#RunProcess) extension to start/stop Selenium automatically *(optional)*. +If you don't plan to use Selenium, tests can be executed directly through ChromeDriver or GeckoDriver. +In this case the driver must be installed and started before running tests. +See the [WebDriver module reference](https://codeception.com/docs/modules/WebDriver#Local-Chrome-andor-Firefox) for how to start each driver and configure the module. ### Configuration From dda5a4d620e242e61df9fc96f46a572f5a2502a5 Mon Sep 17 00:00:00 2001 From: W0rma Date: Sun, 22 Nov 2026 19:20:04 +0100 Subject: [PATCH 02/11] Update outdated tools and claims in guides --- docs/AcceptanceTests.md | 6 +++--- docs/ContinuousIntegration.md | 2 +- docs/Customization.md | 2 +- docs/Data.md | 2 +- docs/ModulesAndHelpers.md | 4 ++-- docs/ParallelExecution.md | 4 ++-- docs/UnitTests.md | 9 +++++++-- docs/reference/Configuration.md | 5 ++--- 8 files changed, 19 insertions(+), 15 deletions(-) diff --git a/docs/AcceptanceTests.md b/docs/AcceptanceTests.md index eba0f1e44..48e169313 100644 --- a/docs/AcceptanceTests.md +++ b/docs/AcceptanceTests.md @@ -561,7 +561,7 @@ For more options see [`performOn()` reference](https://codeception.com/docs/modu When a web site acts unpredictably you may need to react to that change. This happens if a site is configured for A/B testing, or shows different popups, based on environment. -Since Codeception 3.0 you can have some actions to fail silently, if they are errored. +You can have some actions to fail silently, if they are errored. Let's say, you open a page and sometimes there is a popup which should be closed. We may try to hit the "close" button but if this action fails (no popup on page) we just continue the test. @@ -638,8 +638,8 @@ class AcceptanceTester extends \Codeception\Actor ### Cloud Testing -Some environments are hard to reproduce manually, testing Internet Explorer 6-8 on Windows XP may be a hard thing, -especially if you don't have Windows XP installed. This is where Cloud Testing services come to help you. +Some environments are hard to reproduce manually, testing Safari on macOS or browsers on mobile devices may be a hard thing, +especially if you don't have such a device. This is where Cloud Testing services come to help you. Services such as [SauceLabs](https://saucelabs.com), [BrowserStack](https://www.browserstack.com/) and [others](https://codeception.com/docs/modules/WebDriver#Cloud-Testing) can create virtual machines on demand and set up Selenium Server and the desired browser. Tests are executed on a remote machine in a cloud, diff --git a/docs/ContinuousIntegration.md b/docs/ContinuousIntegration.md index 86a8a3f8d..a1c98f9ab 100644 --- a/docs/ContinuousIntegration.md +++ b/docs/ContinuousIntegration.md @@ -101,7 +101,7 @@ jobs: runs-on: ubuntu-latest steps: - name: Checkout - uses: actions/checkout@v4 + uses: actions/checkout@v7 - name: Install PHP uses: shivammathur/setup-php@v2 with: diff --git a/docs/Customization.md b/docs/Customization.md index ab2d1c2df..570d3ae16 100644 --- a/docs/Customization.md +++ b/docs/Customization.md @@ -234,7 +234,7 @@ extensions: The passed in configuration is accessible via the `config` property: `$this->config['param']`. -Check out a very basic extension [Notifier](https://github.com/Codeception/Notifier). +Check out the [extensions shipped with Codeception](https://github.com/Codeception/Codeception/tree/main/ext) for examples. ### Custom Commands diff --git a/docs/Data.md b/docs/Data.md index 069ac5fbe..be76b2957 100644 --- a/docs/Data.md +++ b/docs/Data.md @@ -203,7 +203,7 @@ modules: Doctrine is also a popular ORM, unlike some others it implements the DataMapper pattern and is not bound to any framework. The [Doctrine](https://codeception.com/docs/modules/Doctrine) module requires an `EntityManager` instance to work with. -It can be obtained from a Symfony framework or Zend Framework (configured with Doctrine): +It can be obtained from a Symfony framework or Laminas (configured with Doctrine): ```yaml modules: diff --git a/docs/ModulesAndHelpers.md b/docs/ModulesAndHelpers.md index 578c62971..fb407db26 100644 --- a/docs/ModulesAndHelpers.md +++ b/docs/ModulesAndHelpers.md @@ -413,11 +413,11 @@ params: - env # load params from environment vars ``` -Example: load parameters from YAML file (Symfony): +Example: load parameters from YAML file: ```yaml params: - - app/config/parameters.yml + - config/parameters.yml ``` Example: load parameters from php file (Yii) diff --git a/docs/ParallelExecution.md b/docs/ParallelExecution.md index c3c520969..0ebb6e3ea 100644 --- a/docs/ParallelExecution.md +++ b/docs/ParallelExecution.md @@ -142,7 +142,7 @@ parallel:merge-results #### Step 1: Split Tests -Codeception can organize tests into [groups](https://codeception.com/docs/AdvancedUsage#Groups). Starting from 2.0 it can load information about a group from a file. Sample text file with a list of file names can be treated as a dynamically configured group. Take a look into sample group file: +Codeception can organize tests into [groups](https://codeception.com/docs/AdvancedUsage#Groups). It can load information about a group from a file. Sample text file with a list of file names can be treated as a dynamically configured group. Take a look into sample group file: ```bash @@ -212,7 +212,7 @@ php vendor/bin/codecept run Acceptance -g paracept_2 #### Step 2: Running Tests -At this point you should decide if tests are executed on the same job or use multiple jobs for them. We recommend using multiple jobs, as in this case the burden of parallelization goes to CI server. This makes a lot of sense as a single machine has limited resources. If you split tests into CI jobs, you are limited only to the number of agents (build servers) that the CI can provide. For cloud-based services like GitHub Actions, GitLab CI, CircleCI, etc, this number is unlimited. +At this point you should decide if tests are executed on the same job or use multiple jobs for them. We recommend using multiple jobs, as in this case the burden of parallelization goes to CI server. This makes a lot of sense as a single machine has limited resources. If you split tests into CI jobs, you are limited only to the number of agents (build servers) that the CI can provide. For cloud-based services like GitHub Actions, GitLab CI, CircleCI, etc, this number depends on your plan. > Please refer to documentation of your CI platform to learn how to set up multiple jobs running in parallel. Then proceed to merging of results. diff --git a/docs/UnitTests.md b/docs/UnitTests.md index 219fd79d3..3872bfca5 100644 --- a/docs/UnitTests.md +++ b/docs/UnitTests.md @@ -394,8 +394,9 @@ you will have issues figuring out what tests will be affected by the introductio That's why it's pretty important not just to cover your application with unit tests, but make unit tests self-explanatory. We do this for scenario-driven acceptance and functional tests, and we should do this for unit and integration tests as well. -For this case we have a stand-alone project [Specify](https://github.com/Codeception/Specify) -(which is included in the phar package) for writing specifications inside unit tests: +For this case we have a stand-alone project [Specify](https://github.com/Codeception/Specify) for writing specifications inside unit tests: + +> Specify supports only PHPUnit 8 and 9. ```php DomainAssert supports only PHPUnit 7 to 9. + It allows to reuse business rules inside assertion methods: ```php @@ -471,6 +474,8 @@ With custom assertion methods you can improve readability of your tests and keep Static methods, class methods, date and time functions can be easily replaced with AspectMock. For instance, you can test singletons! +> The latest AspectMock release requires PHP 7.4 and PHPUnit 9, so it can't be installed together with Codeception 5. + ```php Date: Sun, 22 Nov 2026 19:21:41 +0100 Subject: [PATCH 03/11] Add missing content to guides and reference docs --- docs/Customization.md | 4 ++++ docs/GettingStarted.md | 2 ++ docs/ModulesAndHelpers.md | 9 +++++++- docs/Reporting.md | 4 +--- docs/reference/Configuration.md | 4 ++++ docs/reference/Functions.md | 32 ++++++++++++++++++++++++----- docs/reference/ShellAutocomplete.md | 13 +++++++++++- 7 files changed, 58 insertions(+), 10 deletions(-) diff --git a/docs/Customization.md b/docs/Customization.md index 570d3ae16..d10dc1762 100644 --- a/docs/Customization.md +++ b/docs/Customization.md @@ -119,6 +119,8 @@ All listed events are available as constants in `Codeception\Events` class. | Event | When? | Triggered by |:--------------------:| --------------------------------------- | --------------------------: +| `module.init` | Before modules are initialized | [Suite, Settings](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Event/SuiteEvent.php) +| `suite.init` | After modules are initialized | [Suite, Settings](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Event/SuiteEvent.php) | `suite.before` | Before suite is executed | [Suite, Settings](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Event/SuiteEvent.php) | `test.start` | Before test is executed | [Test](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Event/TestEvent.php) | `test.before` | At the very beginning of test execution | [Codeception Test](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Event/TestEvent.php) @@ -129,6 +131,8 @@ All listed events are available as constants in `Codeception\Events` class. | `test.error` | After test ended with error | [Test, Fail](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Event/FailEvent.php) | `test.incomplete` | After executing incomplete test | [Test, Fail](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Event/FailEvent.php) | `test.skipped` | After executing skipped test | [Test, Fail](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Event/FailEvent.php) +| `test.warning` | After test ended with warning | [Test, Fail](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Event/FailEvent.php) +| `test.useless` | After test performed no assertions | [Test, Fail](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Event/FailEvent.php) | `test.success` | After executing successful test | [Test](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Event/TestEvent.php) | `test.after` | At the end of test execution | [Codeception Test](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Event/TestEvent.php) | `test.end` | After test execution | [Test](https://github.com/Codeception/Codeception/blob/main/src/Codeception/Event/TestEvent.php) diff --git a/docs/GettingStarted.md b/docs/GettingStarted.md index 748a7bb6f..db230263b 100644 --- a/docs/GettingStarted.md +++ b/docs/GettingStarted.md @@ -291,8 +291,10 @@ There are plenty of useful Codeception commands: * `generate:helper` *filename* - Generates a sample Helper File * `generate:pageobject` *suite* *filename* - Generates a sample Page object * `generate:stepobject` *suite* *filename* - Generates a sample Step object +* `generate:snapshot` *suite* *filename* - Generates a sample Snapshot class * `generate:environment` *env* - Generates a sample Environment configuration * `generate:groupobject` *group* - Generates a sample Group Extension +* `generate:scenarios` *suite* - Generates text representation for all scenarios ## Conclusion diff --git a/docs/ModulesAndHelpers.md b/docs/ModulesAndHelpers.md index fb407db26..f7ffd0e55 100644 --- a/docs/ModulesAndHelpers.md +++ b/docs/ModulesAndHelpers.md @@ -401,7 +401,7 @@ Use `$this->config['parameter']` to get its value. Modules can be dynamically configured from environment variables. Parameter storage should be specified in the global `codeception.yml` configuration inside the `params` section. -Parameters can be loaded from environment vars, from yaml (Symfony format), .env (Laravel format), ini, or php files. +Parameters can be loaded from environment vars, from yaml (Symfony format), .env (Laravel format), ini, php, or xml files. Use the `params` section of the global configuration file `codeception.yml` to specify how to load them. You can specify several sources for parameters to be loaded from. @@ -427,6 +427,13 @@ params: - config/params.php ``` +Example: load parameters from XML file: + +```yaml +params: + - config/parameters.xml +``` + Example: load parameters from .Env files (Laravel): ```yaml diff --git a/docs/Reporting.md b/docs/Reporting.md index ccbd0266d..390b589b3 100644 --- a/docs/Reporting.md +++ b/docs/Reporting.md @@ -3,9 +3,7 @@ layout: doc title: Reporting - Codeception Docs --- - - -## Reporting +# Reporting Clear reports give a picture of the current state of the system. Which tests are passed, which tests are failed, and if failed what was the reason. Reports may vary on the level of detail and by the technical information collected. Codeception provides built-in reporters and a customizable API to create your own reporter. diff --git a/docs/reference/Configuration.md b/docs/reference/Configuration.md index 2df17d978..8d1e3b6ab 100644 --- a/docs/reference/Configuration.md +++ b/docs/reference/Configuration.md @@ -33,6 +33,10 @@ Allows to enable and configure [Codeception extensions](https://codeception.com/ [Gherkin options](https://codeception.com/docs/BDD#Configuration). +### `groups` + +Defines [groups](https://codeception.com/docs/Customization#Group-Files) for all suites, either as a list of test files and directories or as a path to a group file. + ### `include` Include additional Codeception configurations for [multiple applications setup](https://codeception.com/docs/Customization#One-Runner-for-Multiple-Applications). diff --git a/docs/reference/Functions.md b/docs/reference/Functions.md index c0b212b2c..deb3a04e8 100644 --- a/docs/reference/Functions.md +++ b/docs/reference/Functions.md @@ -11,14 +11,36 @@ Shorthand functions can be used in your Codeception tests or helpers. Prints information when running in debug mode. String, array, or object can be provided as argument. -#### codecept_output_dir() +#### codecept_pause(array $vars = []) -Returns absolute path to output directory (`tests/_output`) +Starts an interactive pause in debug mode. The passed variables are available in the shell. -#### codecept_root_dir() +#### codecept_root_dir($appendPath = '') Returns absolute path to the root directory (where `codeception.yml` is located) -#### codecept_data_dir() +#### codecept_output_dir($appendPath = '') + +Returns absolute path to output directory (`tests/_output`) + +#### codecept_data_dir($appendPath = '') + +Returns absolute path to data directory (`tests/Support/Data`) + +All directory functions append `$appendPath` to the returned path, e.g. `codecept_data_dir('dump.sql')`. + +#### codecept_relative_path($path) + +Returns `$path` relative to the root directory + +#### codecept_absolute_path($path) + +Returns `$path` unchanged if it is absolute, otherwise prepends the root directory + +#### codecept_is_path_absolute($path) + +Checks whether `$path` is absolute + +#### codecept_log() -Returns absolute path to data directory (`tests/Support/Data`) \ No newline at end of file +Returns the `Monolog\Logger` instance of the [Logger](https://codeception.com/extensions#Logger) extension, which must be enabled. diff --git a/docs/reference/ShellAutocomplete.md b/docs/reference/ShellAutocomplete.md index 8a77b40c8..e222f2d98 100644 --- a/docs/reference/ShellAutocomplete.md +++ b/docs/reference/ShellAutocomplete.md @@ -1,4 +1,15 @@ -## Shell auto-completion +--- +layout: doc +title: Shell Autocomplete - Codeception - Documentation +--- + +# Shell Auto-Completion + +Auto-completion requires the optional `stecman/symfony-console-completion` package: + +```bash +composer require --dev stecman/symfony-console-completion +``` For bash and zsh shells, you can use auto-completion for your Codeception projects by executing the following in your shell (or add it to your .bashrc/.zshrc): From 75ba38a7af874cb7e2d9d2ef083596300399caa3 Mon Sep 17 00:00:00 2001 From: W0rma Date: Sun, 22 Nov 2026 19:22:11 +0100 Subject: [PATCH 04/11] Align guide text with its examples --- docs/BDD.md | 4 ++-- docs/Codecoverage.md | 3 --- docs/Customization.md | 2 +- docs/ParallelExecution.md | 2 +- docs/ReusingTestCode.md | 4 ++-- docs/reference/Configuration.md | 12 ++++++------ 6 files changed, 12 insertions(+), 15 deletions(-) diff --git a/docs/BDD.md b/docs/BDD.md index ad0665928..e1805ff88 100644 --- a/docs/BDD.md +++ b/docs/BDD.md @@ -170,7 +170,7 @@ Scenario -- INCOMPLETE Step definition for `I have product with $600 price in my cart` not found in contexts -Step definition for `I have product with $1000 price` not found in contexts +Step definition for `I have product with $1000 price in my cart` not found in contexts Step definition for `I go to checkout process` not found in contexts Step definition for `I should see that total number of products is 2` not found in contexts Step definition for `my order amount is $1600` not found in contexts @@ -292,7 +292,7 @@ class AcceptanceTester extends \Codeception\Actor ``` Please note that `:num1` placeholder can be used for strings and numbers (may contain currency sign). -In current case `:num1` matches `$600` and `$num1` is assigned to be 600. If you need to receive exact string, wrap the value into quotes: `"600$"` +In current case `:num1` matches `$600` and `$num1` is assigned to be 600. If you need to receive exact string, wrap the value into quotes: `"$600"` By default they throw Incomplete exceptions to ensure test with missing steps won't be accidentally marked as successful. We will need to implement those steps. As we are in acceptance suite we are probably using [PhpBrowser](https://codeception.com/docs/modules/PhpBrowser) or [WebDriver](https://codeception.com/docs/modules/WebDriver) modules. This means that we can use their methods inside Tester file, as we do with writing tests using `$I->`. You can use `amOnPage`, `click`, `see` methods inside a step definitions, so each Gherkin scenario step to be extended with basic Codeception steps. Let's show how it can be implemented in our case: diff --git a/docs/Codecoverage.md b/docs/Codecoverage.md index 2529f9dad..7cf18f3c6 100644 --- a/docs/Codecoverage.md +++ b/docs/Codecoverage.md @@ -39,9 +39,6 @@ That's ok for now. But what files should be present in final coverage report? Pass an array of files or directory to include/exclude sections. The path ending with '\*' matches the directory. Also you can use '\*' mask in a file name, i.e. `app/models/*Model.php` to match all models. -There is a shortcut if you don't need that complex filters: - - ```yaml coverage: enabled: true diff --git a/docs/Customization.md b/docs/Customization.md index d10dc1762..52e5248c1 100644 --- a/docs/Customization.md +++ b/docs/Customization.md @@ -28,7 +28,7 @@ you can execute all the tests in a single runner. Run the Codeception tests as u php vendor/bin/codecept run ``` -This will launch the test suites for all three applications and merge the reports from all of them. +This will launch the test suites for all included applications and merge the reports from all of them. This is very useful when you run your tests on a Continuous Integration server and you want to get a single report in JUnit and HTML format. The code coverage report will be merged too. diff --git a/docs/ParallelExecution.md b/docs/ParallelExecution.md index 0ebb6e3ea..5180df135 100644 --- a/docs/ParallelExecution.md +++ b/docs/ParallelExecution.md @@ -15,7 +15,7 @@ In this guide we will overview possible options. ## Sharding Minimal setup can be implemented by executing several independent CI jobs, each running a part of the tests. -Sharding in Codeception allows to combine stages 1 and 2 so tests could be split by groups on the fly. +Sharding in Codeception allows to combine the splitting and running stages (see [Building Pipeline](#Building-Pipeline)) so tests could be split by groups on the fly. In this case a pipeline could be simplified to one stage with several jobs. ![](/images/codeception-sharding.png) diff --git a/docs/ReusingTestCode.md b/docs/ReusingTestCode.md index 39799f589..cf6798938 100644 --- a/docs/ReusingTestCode.md +++ b/docs/ReusingTestCode.md @@ -84,12 +84,12 @@ This trait was created by running `codecept build` and is regenerated each time ## PageObjects -For acceptance and functional testing, we will not only need to have common actions being reused across different tests, +For acceptance testing, we will not only need to have common actions being reused across different tests, we should have buttons, links and form fields being reused as well. For those cases we need to implement the [PageObject pattern](https://www.selenium.dev/documentation/test_practices/encouraged/page_object_models/), which is widely used by test automation engineers. The PageObject pattern represents a web page as a class and the DOM elements on that page as its properties, and some basic interactions as its methods. -PageObjects are very important when you are developing a flexible architecture of your acceptance or functional tests. +PageObjects are very important when you are developing a flexible architecture of your acceptance tests. Do not hard-code complex CSS or XPath locators in your tests but rather move them into PageObject classes. Codeception can generate a PageObject class for you with command: diff --git a/docs/reference/Configuration.md b/docs/reference/Configuration.md index 8d1e3b6ab..35cf935cb 100644 --- a/docs/reference/Configuration.md +++ b/docs/reference/Configuration.md @@ -11,7 +11,7 @@ The global configuration file `codeception.yml` is generated by the `codecept bo ### `actor_suffix` -Sets the suffix for "Actor" classes. Default: `Tester`. If you set it to `Ninja` and generate a new `api` test suite, you will get an `ApiNinja` actor class. +Sets the suffix for "Actor" classes. Default: `Tester`. If you set it to `Ninja` and generate a new `Api` test suite, you will get an `ApiNinja` actor class. ### `bootstrap` @@ -65,7 +65,7 @@ Allows to pass [external parameters](https://codeception.com/docs/ModulesAndHelp ### `paths` -Directories used by Codeception. Default values: +Directories used by Codeception. Values set by `codecept bootstrap`: {% highlight yaml %} paths: @@ -138,6 +138,10 @@ Override any configuration per [environment](https://codeception.com/docs/Advanc Allows you to specify a file (relative to `*.suite.yml`) that holds some already pre-defined values. This can be used to always use the same configuration for modules or whatever. +### `formats` + +[formats](https://codeception.com/docs/Customization#Formats) with the list of extra test format classes. + ### `gherkin` Per suite [Gherkin](https://codeception.com/docs/BDD#Configuration) settings. @@ -146,10 +150,6 @@ Per suite [Gherkin](https://codeception.com/docs/BDD#Configuration) settings. [groups](https://codeception.com/docs/AdvancedUsage#Groups) with the list of tests for the corresponding group. -### `formats` - -[formats](https://codeception.com/docs/Customization#Formats) with the list of extra test format classes. - ### `modules` List of enabled modules with their configuration. From 839631d99260af3940b1df272acf755c911b1689 Mon Sep 17 00:00:00 2001 From: W0rma Date: Sat, 28 Nov 2026 15:39:12 +0100 Subject: [PATCH 05/11] Fix API testing setup in Yii guide --- for/yii.md | 28 +++++++++++++++++++--------- 1 file changed, 19 insertions(+), 9 deletions(-) diff --git a/for/yii.md b/for/yii.md index 86575245c..2df68a2ed 100644 --- a/for/yii.md +++ b/for/yii.md @@ -38,7 +38,7 @@ Run them by executing in terminal: Unit tests are located in `tests/Unit` directory and are supposed to contain all kind of unit and integration testing. Each test case extends `Codeception\Test\Unit` class, which is standard Codeception format for unit testing. - It is pretty hard to develop completely isolated unit tests in Yii, so an application is bootstrapped before each test case. Tests are configured in `tests/unit.suite.yml` file with Yii2 module enabled: + It is pretty hard to develop completely isolated unit tests in Yii, so an application is bootstrapped before each test case. Tests are configured in `tests/Unit.suite.yml` file with Yii2 module enabled: ```yaml modules: @@ -109,7 +109,7 @@ Codeception provides standard set of actions like `amOnPage`, `submitForm`, `see Functional tests should be written inside [Cest files](https://codeception.com/docs/07-AdvancedUsage#Cest-Classes), which is a scenario-driven test format of Codeception. You can easily create a new test by running: ``` -./vendor/bin/codecept g:cest functional MyNewScenarioCest +./vendor/bin/codecept g:cest Functional MyNewScenarioCest ```
@@ -120,26 +120,36 @@ Functional tests should be written inside [Cest files](https://codeception.com/d ### API Tests -API tests are not included in any Yii templates so you need to set up them manually if you developing a web service. API testing is done at functional testing level but instead of testing HTML responses on user actions, they test requests and responses via protocols like REST or SOAP. To start writing api tests you should create a suite for them +API tests are not included in any Yii templates so you need to set them up manually if you are developing a web service. API testing is done at functional testing level but instead of testing HTML responses on user actions, they test requests and responses via protocols like REST or SOAP. API tests require the REST module, which is not installed by default: ``` -./vendor/bin/codecept g:suite api +composer require codeception/module-rest --dev ``` -You will need to enable `REST`, `Yii2` module in `tests/api.suite.yml`: +To start writing API tests you should create a suite for them: + +``` +./vendor/bin/codecept g:suite Api +``` + +You will need to enable the `REST` module in `tests/Api.suite.yml`: ```yaml -class_name: ApiTester +actor: ApiTester modules: enabled: - REST: url: /api/v1 depends: Yii2 - - \ApiBundle\Helper\Api - ``` -Yii2 module actions like `amOnPage` or `see` should not be available for testing API. This is why Yii2 module is not enabled but declared with `depends` for REST module. +Yii2 module actions like `amOnPage` or `see` should not be available for testing API. This is why Yii2 module is not enabled but declared with `depends` for REST module. The `configFile` for Yii2 is taken from the global `codeception.yml`, so it doesn't need to be repeated here. + +Run `./vendor/bin/codecept build` after changing the enabled modules, then create your first API test: + +``` +./vendor/bin/codecept g:cest Api CreateUserCest +```
From 6f52960f89a78e0ad2a8260cd4659a9aae2fdcb8 Mon Sep 17 00:00:00 2001 From: W0rma Date: Sat, 28 Nov 2026 15:41:26 +0100 Subject: [PATCH 06/11] Fix acceptance suite config path in Yii guide --- for/yii.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/for/yii.md b/for/yii.md index 2df68a2ed..6ba346ff4 100644 --- a/for/yii.md +++ b/for/yii.md @@ -177,7 +177,7 @@ Then you will need to launch application server in test mode: and start a [Selenium Server](https://codeception.com/docs/modules/WebDriver#Local-Testing). For acceptance WebDriver module is used. Please check its reference to learn how to work with it. Unlike Yii2 module it does know nothing about your application, so if you want to use features of Yii like fixtures for acceptance testing, you should check that enable Yii2 module is enabled as well: ```yml -# config at tests/Acceptance.yml +# config at tests/Acceptance.suite.yml modules: enabled: - WebDriver: From ab9e9da39571db916c0e1e965fc4c98db0849511 Mon Sep 17 00:00:00 2001 From: W0rma Date: Sat, 28 Nov 2026 15:41:26 +0100 Subject: [PATCH 07/11] Replace class_name with actor in Laravel and Phalcon guides --- for/laravel.md | 8 ++++---- for/phalcon.md | 4 ++-- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/for/laravel.md b/for/laravel.md index f16ab6101..1d4408e01 100644 --- a/for/laravel.md +++ b/for/laravel.md @@ -50,7 +50,7 @@ Functional tests allow test application by simulating user actions, this is done To start you need to configure `tests/Functional.suite.yml` to use Laravel module: ```yaml -class_name: FunctionalTester +actor: FunctionalTester modules: enabled: - Laravel: @@ -93,7 +93,7 @@ Enable Laravel module in `Unit.suite.yml` to have its methods inside a testcase. To test an application in a real environment by using its UI you should use a real browser. Codeception uses Selenium Webdriver and corresponding WebDriver module to interact with a browser. You should configure `Acceptance.suite.yml` to use WebDriver module and a browser of your choice. ```yaml -class_name: AcceptanceTester +actor: AcceptanceTester modules: enabled: - WebDriver: @@ -109,7 +109,7 @@ Acceptance tests will be executed in development environment using real web serv You can also use Eloquent to create data for acceptance tests. This way you can use data factories and models to prepare and cleanup data for tests. You should enable Laravel module with ORM part to add ActiveRecord methods: ```yaml -class_name: AcceptanceTester +actor: AcceptanceTester modules: enabled: - WebDriver: @@ -134,7 +134,7 @@ php vendor/bin/codecept g:suite api You will need to enable `REST`, `Laravel` module in `tests/api.suite.yml`: ```yaml -class_name: ApiTester +actor: ApiTester modules: enabled: - REST: diff --git a/for/phalcon.md b/for/phalcon.md index e6dde6840..fc323d274 100644 --- a/for/phalcon.md +++ b/for/phalcon.md @@ -141,7 +141,7 @@ class LoginCest Sample configuration of `tests/Acceptance.suite.yml`: ```yaml -class_name: AcceptanceTester +actor: AcceptanceTester modules: enabled: - WebDriver: @@ -203,7 +203,7 @@ vendor/bin/codecept g:suite api You will need to enable `REST` and `Phalcon` module in `tests/api.suite.yml`: ```yaml -class_name: ApiTester +actor: ApiTester modules: enabled: - Phalcon4: From 32461ea1d17b96d825b4e384838d39fec19839c3 Mon Sep 17 00:00:00 2001 From: W0rma Date: Sat, 28 Nov 2026 15:45:52 +0100 Subject: [PATCH 08/11] Use upper-cased suite names in Laravel and Phalcon guides --- for/laravel.md | 6 +++--- for/phalcon.md | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/for/laravel.md b/for/laravel.md index 1d4408e01..442f7af32 100644 --- a/for/laravel.md +++ b/for/laravel.md @@ -69,7 +69,7 @@ Codeception will also use **Eloquent to cleanup changes to database** by wrappin To create first functional test for `Login` you should run: ``` -php vendor/bin/codecept g:cest functional Login +php vendor/bin/codecept g:cest Functional Login ``` ## Unit Tests @@ -128,10 +128,10 @@ Laravel module won't be able to wrap test execution in a transaction but methods API Tests are done at functional testing level but instead of testing HTML responses on user actions, they test requests and responses via protocols like REST or SOAP. To create api tests you should create a suite for them ``` -php vendor/bin/codecept g:suite api +php vendor/bin/codecept g:suite Api ``` -You will need to enable `REST`, `Laravel` module in `tests/api.suite.yml`: +You will need to enable `REST`, `Laravel` module in `tests/Api.suite.yml`: ```yaml actor: ApiTester diff --git a/for/phalcon.md b/for/phalcon.md index fc323d274..7149fb03a 100644 --- a/for/phalcon.md +++ b/for/phalcon.md @@ -173,13 +173,13 @@ vendor/bin/codecept run Acceptance ### BDD -If you prefer to describe application with feature files, Codeception can turn them to acceptance tests. It is recommended to store feature files in `features` directory (like Behat does it) but symlinking it to `tests/acceptance/features` so they can be treated as tests too. +If you prefer to describe application with feature files, Codeception can turn them to acceptance tests. It is recommended to store feature files in `features` directory (like Behat does it) but symlinking it to `tests/Acceptance/features` so they can be treated as tests too. ``` ln -s $PWD/features tests/Acceptance ``` -Codeception allows to combine tests written in different formats. If you are about to write a regression test it probably should not be described as a product's feature. That's why feature-files are a subset of all acceptance tests, and they are stored in subfolder of `tests/acceptance`. +Codeception allows to combine tests written in different formats. If you are about to write a regression test it probably should not be described as a product's feature. That's why feature-files are a subset of all acceptance tests, and they are stored in subfolder of `tests/Acceptance`. There are no standard Gherkin steps built in. By writing your feature files you can get code snippets which should be added to `AcceptanceTester` class. @@ -197,10 +197,10 @@ vendor/bin/codecept gherkin:snippets API Tests are done at functional testing level but instead of testing HTML responses on user actions, they test requests and responses via protocols like REST or SOAP. To create api tests, you should create a suite for them: ``` -vendor/bin/codecept g:suite api +vendor/bin/codecept g:suite Api ``` -You will need to enable `REST` and `Phalcon` module in `tests/api.suite.yml`: +You will need to enable `REST` and `Phalcon` module in `tests/Api.suite.yml`: ```yaml actor: ApiTester From 4c9b4369008facb1435979991af6327cf00c2e7a Mon Sep 17 00:00:00 2001 From: W0rma Date: Sat, 28 Nov 2026 15:45:56 +0100 Subject: [PATCH 09/11] Remove Codeception 4 helper modules from Laravel and Phalcon guides --- for/laravel.md | 4 ---- for/phalcon.md | 4 ---- 2 files changed, 8 deletions(-) diff --git a/for/laravel.md b/for/laravel.md index 442f7af32..47fe5269a 100644 --- a/for/laravel.md +++ b/for/laravel.md @@ -55,7 +55,6 @@ modules: enabled: - Laravel: environment_file: .env.testing - - \AppBundle\Helper\Functional ``` @@ -99,7 +98,6 @@ modules: - WebDriver: url: 'https://localhost/' # put your local url browser: firefox - - \Helper\Acceptance ``` Browser can be specified as `firefox`, `chrome`, or others. @@ -118,7 +116,6 @@ modules: - Laravel: part: ORM cleanup: false # can't wrap into transaction - - \Helper\Acceptance ``` Laravel module won't be able to wrap test execution in a transaction but methods like `haveRecord` or `haveModel` will delete objects they created when test ends. @@ -140,7 +137,6 @@ modules: - REST: url: /api/v1 depends: Laravel - - \Helper\Api config: Laravel: environment_file: .env.testing diff --git a/for/phalcon.md b/for/phalcon.md index 7149fb03a..8db7aa637 100644 --- a/for/phalcon.md +++ b/for/phalcon.md @@ -46,7 +46,6 @@ actor: UnitTester modules: enabled: - Asserts - - \Helper\Unit - Phalcon4: bootstrap: public/index.php cleanup: true @@ -85,7 +84,6 @@ actor: FunctionalTester modules: enabled: # add a framework module here - - \Helper\Functional - Phalcon4: bootstrap: public/index.php cleanup: true @@ -147,7 +145,6 @@ modules: - WebDriver: url: 'https://localhost/' # put your local url browser: chrome - - \Helper\Acceptance ``` Browser can be specified as `chrome`, `firefox`, `phantomjs`, or others. @@ -213,7 +210,6 @@ modules: - REST: url: /v1 depends: Phalcon4 - - \Helper\Api ``` Phalcon [module](/docs/modules/Phalcon4) actions like `amOnPage` or `see` should not be available for testing API. This is why Phalcon module is not enabled but declared with `depends` for REST module. But Phalcon module should be configured to load Kernel class from `app_path`. From b0173d205532326aa4033d4f2138e25e27e52931 Mon Sep 17 00:00:00 2001 From: W0rma Date: Sat, 28 Nov 2026 15:45:56 +0100 Subject: [PATCH 10/11] Remove PhantomJS from Phalcon guide --- for/phalcon.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/for/phalcon.md b/for/phalcon.md index 8db7aa637..6ee373380 100644 --- a/for/phalcon.md +++ b/for/phalcon.md @@ -147,7 +147,7 @@ modules: browser: chrome ``` -Browser can be specified as `chrome`, `firefox`, `phantomjs`, or others. +Browser can be specified as `chrome`, `firefox`, or others. To create a sample test called, run: From 39f08b3ae16f43d661c033bac181be1994fc0de4 Mon Sep 17 00:00:00 2001 From: W0rma Date: Sat, 28 Nov 2026 15:46:09 +0100 Subject: [PATCH 11/11] Update outdated doc links in framework guides --- for/laravel.md | 8 ++++---- for/phalcon.md | 12 ++++++------ for/yii.md | 16 ++++++++-------- 3 files changed, 18 insertions(+), 18 deletions(-) diff --git a/for/laravel.md b/for/laravel.md index 47fe5269a..c5f3bbf7a 100644 --- a/for/laravel.md +++ b/for/laravel.md @@ -60,7 +60,7 @@ modules: Codeception will also use **Eloquent to cleanup changes to database** by wrapping tests into transaction and rolling it back in the end of a test. This makes tests isolated and fast. Laravel module allows to access services from DIC container, user authentication methods, fixture generators, check form validations and more. @@ -83,7 +83,7 @@ Enable Laravel module in `Unit.suite.yml` to have its methods inside a testcase.
- Continue to Unit Testing Guide ». + Continue to Unit Testing Guide ».
@@ -148,7 +148,7 @@ Laravel module actions like `amOnPage` or `see` should not be available for test ### BDD @@ -171,5 +171,5 @@ In the same manner features can be set up as functional tests. diff --git a/for/phalcon.md b/for/phalcon.md index 6ee373380..c68118cac 100644 --- a/for/phalcon.md +++ b/for/phalcon.md @@ -63,7 +63,7 @@ Actions of the Phalcon module will be accessible from `$this->tester` inside a t
- Continue to Unit Testing Guide ». + Continue to Unit Testing Guide ».
## Functional Tests @@ -91,7 +91,7 @@ modules: step_decorators: ~ ``` -Then use [Cest](https://codeception.com/docs/07-AdvancedUsage) or Cept to create a test. +Then use [Cest](https://codeception.com/docs/AdvancedUsage) or Cept to create a test. ``` vendor/bin/codecept g:cest Functional Login ``` @@ -131,7 +131,7 @@ class LoginCest ### Acceptance Testing @@ -159,7 +159,7 @@ This will create the file `tests/Acceptance/LoginCest.php`. Each method of a cla To run the tests you will need chrome browser, [selenium server running](https://codeception.com/docs/modules/WebDriver#Selenium). If this requirements met acceptance tests can be executed as @@ -186,7 +186,7 @@ vendor/bin/codecept gherkin:snippets ### API Tests @@ -217,7 +217,7 @@ Phalcon [module](/docs/modules/Phalcon4) actions like `amOnPage` or `see` should [Edit this page on GitHub](https://github.com/Codeception/codeception.github.com/blob/master/for/phalcon.md) diff --git a/for/yii.md b/for/yii.md index 6ba346ff4..ae55ebbd0 100644 --- a/for/yii.md +++ b/for/yii.md @@ -79,11 +79,11 @@ $this->tester->haveFixtures([ $this->tester->grabFixture('user', 0); ``` -If `Yii2` module is enabled you can safely call `Yii::$app` inside a test, as application is initialized and cleaned up after a test. If you want to add your helper methods or custom assertions for your test case you should not extend `Codeception\Test\Unit` but write your own separate [Helper class](https://codeception.com/docs/06-ModulesAndHelpers#Helpers). +If `Yii2` module is enabled you can safely call `Yii::$app` inside a test, as application is initialized and cleaned up after a test. If you want to add your helper methods or custom assertions for your test case you should not extend `Codeception\Test\Unit` but write your own separate [Helper class](https://codeception.com/docs/ModulesAndHelpers#Helpers).
- Continue to Unit Testing Guide » + Continue to Unit Testing Guide »
@@ -106,7 +106,7 @@ $I->see('Body cannot be blank'); This way you not only test the ContactForm on a site but actual output of application that user sees. Codeception provides standard set of actions like `amOnPage`, `submitForm`, `see` for testing. Yii2 module provides special methods, like `amLoggedInAs` (for fast authentication), `haveRecord`, `seeRecord`, `seeEmailIsSent` and others. They all are listed in [module reference](https://codeception.com/docs/modules/Yii2). -Functional tests should be written inside [Cest files](https://codeception.com/docs/07-AdvancedUsage#Cest-Classes), which is a scenario-driven test format of Codeception. You can easily create a new test by running: +Functional tests should be written inside [Cest files](https://codeception.com/docs/AdvancedUsage#Cest-Classes), which is a scenario-driven test format of Codeception. You can easily create a new test by running: ``` ./vendor/bin/codecept g:cest Functional MyNewScenarioCest @@ -115,7 +115,7 @@ Functional tests should be written inside [Cest files](https://codeception.com/d
Functional tests are really powerful and simple. They are highly recommended to use for any Yii application.
- Continue to Functional Testing Guide » + Continue to Functional Testing Guide »
### API Tests @@ -153,7 +153,7 @@ Run `./vendor/bin/codecept build` after changing the enabled modules, then creat ### Acceptance Tests @@ -174,7 +174,7 @@ Then you will need to launch application server in test mode: ./tests/bin/yii serve ``` -and start a [Selenium Server](https://codeception.com/docs/modules/WebDriver#Local-Testing). For acceptance WebDriver module is used. Please check its reference to learn how to work with it. Unlike Yii2 module it does know nothing about your application, so if you want to use features of Yii like fixtures for acceptance testing, you should check that enable Yii2 module is enabled as well: +and start a [Selenium Server](https://codeception.com/docs/modules/WebDriver#Selenium-Recommended). For acceptance WebDriver module is used. Please check its reference to learn how to work with it. Unlike Yii2 module it does know nothing about your application, so if you want to use features of Yii like fixtures for acceptance testing, you should check that enable Yii2 module is enabled as well: ```yml # config at tests/Acceptance.suite.yml @@ -199,7 +199,7 @@ Similar as for functional tests it is recommended to use Cest format for accepta ## Yii Advanced @@ -212,7 +212,7 @@ Tests also include namespaces for testcase classes and testers to avoid conflict ## Manual Setup && Configuration