Translations
Info
All page names need to be in English.
en da  de  fr  it  ja  km  nl  ru  zh

Acceptance testing

From TYPO3Wiki
Jump to: navigation, search

<< Back to Document matrix

see also: Category:PHPUnit

Acceptance Testing since TYPO3 v8

Since the very early version of TYPO3 v8, the core ships with Acceptance tests based on Codeception, which are executed with selenium and browsers like Firefox.

Fetch the TYPO3 sources, install composer dependencies and start the selenium server and the PHP HTTP server:

shell script:
git clone git://git.typo3.org/Packages/TYPO3.CMS.git
cd TYPO3.CMS/
composer install
mkdir -p typo3temp/var/tests 
./bin/selenium-server-standalone >/dev/null 2>&1 &
php -S 0.0.0.0:8000 >/dev/null 2>&1 &
sleep 3;

This will start the selenium server and put it into the background. It only needs to be started once!

Note: If this fails, download the latest Java JDK from Oracle at http://www.oracle.com/technetwork/java/javase/downloads/jdk7-downloads-1880260.html and install it.

Acceptance tests rely on a TYPO3 installation, so you need to have a MySQL/MariaDB database running and a database user with proper permissions. Make sure the database user is permitted to create databases and tables:

shell script:
# Set up a DB user with permissions for any DB, whose name starts with t3_core_test_
GRANT ALL ON `t3_core_test\_%`.* TO '<user>'@'localhost' IDENTIFIED BY '<password>';

Execute the following command to run all Acceptance Tests which are shipped by the core. By default they are run in firefox browser (currently the only supported environment to run the tests in):

shell script:
typo3DatabaseName='t3_core_test' typo3DatabaseHost='localhost' typo3DatabaseUsername='<user>' typo3DatabasePassword='<password>' ./bin/codecept run Acceptance -c typo3/sysext/core/Build/AcceptanceTests.yml

notice - Note

Using TYPO3 v8.6 or later:

The location for the configuration file typo3/sysext/core/Build/AcceptanceTests.yml has changed and is now located here:

components/testing_framework/core/Build/AcceptanceTests.yml
see also: 79025: Core - Extract testing framework for TYPO3 [Resolved; assigned to Susanne Moog]

If you want to just execute a group of tests or a single test you can simply add the "testname" or the filename to the test.

shell script:
# execute all tests defined in "Backend/Extensionmanager"
typo3DatabaseName='t3_core_test' typo3DatabaseHost='localhost' typo3DatabaseUsername='<user>' typo3DatabasePassword='<password>' ./bin/codecept run Acceptance -c typo3/sysext/core/Build/AcceptanceTests.yml Backend/Extensionmanager

# execute just the test "checkIfUploadFormAppears" of the "Backend/Extensionmanager" group.
typo3DatabaseName='t3_core_test' typo3DatabaseHost='localhost' typo3DatabaseUsername='<user>' typo3DatabasePassword='<password>' ./bin/codecept run Acceptance -c typo3/sysext/core/Build/AcceptanceTests.yml Backend/Extensionmanager:checkIfUploadFormAppears

The test suite is created so that it do not need a working typo3 instance below at all. It basically set up its own instance within typo3temp/var/tests, creates a LocalConfiguration with given db credentials and work on that. The background is that the tests need a "defined state" of the system, so a defined set of loaded extensions for instance. That is why database credentials are needed, that they can work on, so they create a fully separated db, with own db fixture rows (like be_users to log in).

Windows users

similar like the above, just instead of the last line:

shell script:
set typo3DatabaseName=yourDatabase  
set typo3DatabaseHost=yourHost
set typo3DatabaseUsername=yourUser
set typo3DatabasePassword=yourPassword
./bin/codecept run Acceptance -c typo3/sysext/core/Build/AcceptanceTests.yml Backend/Extensionmanager:checkIfUploadFormAppears

Testing with Chrome

If you want to run acceptance tests with Google Chrome, just change line "browser: firefox" in typo3/sysext/core/Tests/Acceptance.suite.yml to "browser: chrome", and download latest chrome driver from http://chromedriver.storage.googleapis.com/index.html and put the binary is in the system path e.g. /usr/bin/chromedriver After that execute tests as described above.

3rd party extensions

The acceptance test suite however was not fully set up to support tests from 3rd party (non-core) extensions.


Debugging tips

Interactive console

Codeception comes with an interactive console. See http://codeception.com/docs/07-AdvancedUsage

Pause on failue

You can force Codeception to keep the browser open after test fails, so you can investigate the error. Just put following code in your Cest file: The test execution will be paused until you hit enter in the console.

    public function _failed(\AcceptanceTester $I)
    {
         $I->pauseExecution();
    }