mirror of https://github.com/FriendsOfTYPO3/tea.git synced 2024-11-22 09:36:13 +01:00

[FEATURE] Example acceptance tests with Codeception (#31)

This commit is contained in:
Oliver Klee 2018-05-31 23:48:38 +02:00 committed by GitHub
parent 5b3936f35a
commit fd3f73af13
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 127 additions and 0 deletions

View file

@ -64,6 +64,24 @@ In the Run configurations, copy the PHPUnit configuration and use these settings
- [x] Use alternative configuration file
- use `.Build/vendor/nimut/testing-framework/res/Configuration/FunctionalTests.xml`
### Running the acceptance tests
#### On the command line
1. make sure you have Chrome installed on your machine
2. `composer update codeception/codeception` (just in case)
3. [download the latest version of ChromeDriver](http://chromedriver.chromium.org/downloads)
4. unzip it
5. `chromedriver --url-base=/wd/hub &`
6. `.Build/vendor/bin/codecept run`
7. Run 'Acceptance (Codeception)'
#### In PhpStorm
1. make sure the "Codeception Framework" plugin is activated
2. right-click on `Tests/Acceptance`
## Creating new extensions with automated tests
For creating new extensions, I recommend taking

View file

@ -0,0 +1,28 @@
<?php
declare(strict_types = 1);
namespace OliverKlee\Tea\Tests\Acceptance;
/**
* Test case.
*
* @author Oliver Klee <typo3-coding@oliverklee.de>
*/
class StarterCest
{
public function _before(\AcceptanceTester $I)
{
$I->amOnPage('/');
}
public function seeAuthorName(\AcceptanceTester $I)
{
$I->see('Oliver Klee');
}
public function canNavigateToPastWorkshops(\AcceptanceTester $I)
{
$I->click('Workshops');
$I->click('Rückblick');
$I->see('2017 (17)');
}
}

View file

@ -0,0 +1,26 @@
<?php
/**
* Inherited Methods
* @method void wantToTest($text)
* @method void wantTo($text)
* @method void execute($callable)
* @method void expectTo($prediction)
* @method void expect($prediction)
* @method void amGoingTo($argumentation)
* @method void am($role)
* @method void lookForwardTo($achieveValue)
* @method void comment($description)
* @method \Codeception\Lib\Friend haveFriend($name, $actorClass = NULL)
*
* @SuppressWarnings(PHPMD)
*/
class AcceptanceTester extends \Codeception\Actor
{
use _generated\AcceptanceTesterActions;
/**
* Define custom actions here
*/
}

View file

@ -0,0 +1,10 @@
<?php
namespace Helper;
// here you can define custom actions
// all public methods declared in helper class will be available in $I
class Acceptance extends \Codeception\Module
{
}

View file

@ -0,0 +1,2 @@
*
!.gitignore

41
codeception.yml Normal file
View file

@ -0,0 +1,41 @@
# suite config
suites:
acceptance:
actor: AcceptanceTester
path: .
modules:
enabled:
- WebDriver:
url: https://www.oliverklee.de
browser: chrome
- \Helper\Acceptance
extensions:
enabled: [Codeception\Extension\RunFailed]
params:
- env
gherkin: []
# additional paths
paths:
tests: Tests/Acceptance
output: .Build/public/typo3temp/var/tests/_output
data: .Build/public/typo3temp/var/tests/_data
support: Tests/Acceptance/_support
envs: .Build/public/typo3temp/var/tests/_envs
settings:
shuffle: false
lint: true
modules:
config:
WebDriver:
browser: chrome
port: 9515 # ChromeDriver port
window_size: false
capabilities:
chromeOptions:
args: ["--headless", "--disable-gpu"]

View file

@ -36,6 +36,8 @@
"helhum/typo3-composer-setup": "^0.5.1",
"helmich/typo3-typoscript-lint": "^1.4.4",
"nimut/testing-framework": "^3.0",
"codeception/codeception": "^2.4",
"enm1989/chromedriver": "^2.38",
"roave/security-advisories": "dev-master"
},
"replace": {