Running functional tests
Functional tests execute test cases within a fully initialized TYPO3 instance. Unlike unit tests, functional tests interact with the TYPO3 framework, service container, and an active database connection.
Before running functional tests, ensure that the TYPO3 testing framework ( typo3/testing-framework ) and PHPUnit ( phpunit/phpunit ) are installed as Composer development dependencies. For version compatibility between TYPO3, PHP, and the testing framework, see Install PHPUnit and the TYPO3 testing framework.
Quick setup with extension kickstarter
If you are developing a TYPO3 extension, the fastest way to set up the test environment is using the Extension Kickstarter ( friendsoftypo3/kickstarter ):
composer require --dev friendsoftypo3/kickstarter
vendor/bin/typo3 make:testenv [extension_key]
The command generates:
Build/andphpunit/ Functional Tests. xml Build/phpunit/ Functional Tests Bootstrap. php Build/andphpunit/ Unit Tests. xml Build/phpunit/ Unit Tests Bootstrap. php Build/(the containerized test runner)Scripts/ run Tests. sh - Standard configuration files for coding guidelines and static analysis
(such as
.php-andcs- fixer. dist. php phpstan.)neon - Enriches
composer.with the necessaryjson require-anddev autoload-definitionsdev
For more information, see Testing extensions.
Provide configuration files for functional tests
If you set up testing manually or need to customize an existing configuration, the TYPO3 testing framework provides template files:
- vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTests.xml
- vendor/typo3/testing-framework/Resources/Core/Build/FunctionalTestsBootstrap.php
Copy these files into your project under Build/.
Open Functional and adjust the path in the <testsuite>
definition to point to your functional test directory. Because the
configuration file is located two directory levels deep in
Build/, use ../../ to navigate back to the root directory.
By convention, functional tests reside in Tests/:
<testsuites>
<testsuite name="Functional tests">
- <directory>../../../../../../typo3/sysext/*/Tests/Functional/</directory>
+ <directory>../../Tests/Functional/</directory>
</testsuite>
</testsuites>
For testing within a full project with local extensions in packages/:
<testsuites>
<testsuite name="Functional tests">
- <directory>../../../../../../typo3/sysext/*/Tests/Functional/</directory>
+ <directory>../../Tests/Functional/</directory>
+ <directory>../../packages/*/Tests/Functional/</directory>
</testsuite>
</testsuites>
The bootstrap file Functional instantiates
\TYPO3\, resolves paths, and ensures the
temporary directories typo3temp/ and
typo3temp/ exist before executing test suites.
Run functional tests with runTests.sh
The recommended and standardized approach for running tests across TYPO3
extensions is Build/. It starts dedicated Docker
containers with all required dependencies and manages database containers
automatically.
When using run, you do not need to configure database
credentials or set environment variables manually. The script takes care of
starting the database service (SQLite, MariaDB, or PostgreSQL) and injecting all
necessary configuration variables into the test environment.
Run all functional tests using the default database (SQLite):
Build/Scripts/runTests.sh -s functional
Run tests against a specific database system:
Build/Scripts/runTests.sh -s functional -d mariadb
Build/Scripts/runTests.sh -s functional -d postgres
Run tests with a specific PHP version:
Build/Scripts/runTests.sh -s functional -p 8.4
Run a single test file:
Build/Scripts/runTests.sh -s functional -- \
Tests/Functional/Domain/Repository/MyRepositoryTest.php
For more details on run options and workflows, see
Test runners.
Run functional tests on the host system or with DDEV
If you choose not to use run and execute PHPUnit directly on
your host system or inside DDEV, you must provide the database connection
details yourself via environment variables.
Functional tests create the database schema based on the TCA configuration and
complementary ext_tables.sql definitions of all loaded extensions, and
truncate database tables between tests. Without run managing
the environment, the test bootstrap requires the following environment
variables:
typo3DatabaseDriver -
Specifies the database driver:
pdo_: Uses an SQLite file database. This is the simplest driver for local execution because it requires no database server setup or credentials. SQLite creates database files on the fly insqlite typo3temp/.var/ tests/ functional- sqlite- dbs/ mysqli: Connects to a MySQL or MariaDB database server.pdo_: Connects to a PostgreSQL database server.pgsql
If using mysqli or pdo_, the following additional connection
variables must be supplied:
typo3Database(e.g.Host 127.or0. 0. 1 db)typo3Database(e.g.Port 3306)typo3DatabaseUsername typo3DatabasePassword typo3DatabaseName
These variables can either be passed inline when executing PHPUnit, or defined
in the <php> section of Build/:
<php>
<ini name="display_errors" value="1"/>
<env name="TYPO3_CONTEXT" value="Testing"/>
<env name="typo3DatabaseDriver" value="pdo_sqlite"/>
</php>
Running with SQLite on DDEV:
ddev exec typo3DatabaseDriver=pdo_sqlite \
php vendor/bin/phpunit -c Build/phpunit/FunctionalTests.xml
Running with MariaDB or MySQL on DDEV:
ddev exec \
typo3DatabaseDriver=mysqli \
typo3DatabaseHost=db \
typo3DatabasePort=3306 \
typo3DatabaseUsername=db \
typo3DatabasePassword=db \
typo3DatabaseName=db_test \
php vendor/bin/phpunit -c Build/phpunit/FunctionalTests.xml
To run a single test method or test case, use the -- option:
ddev exec typo3DatabaseDriver=pdo_sqlite \
php vendor/bin/phpunit -c Build/phpunit/FunctionalTests.xml \
--filter "MyFunctionalTest"