mirror of
https://github.com/FriendsOfTYPO3/tea.git
synced 2024-11-10 04:56:12 +01:00
[FEATURE] Example acceptance tests with Codeception (#31)
This commit is contained in:
parent
5b3936f35a
commit
fd3f73af13
7 changed files with 127 additions and 0 deletions
18
README.md
18
README.md
|
@ -64,6 +64,24 @@ In the Run configurations, copy the PHPUnit configuration and use these settings
|
||||||
- [x] Use alternative configuration file
|
- [x] Use alternative configuration file
|
||||||
- use `.Build/vendor/nimut/testing-framework/res/Configuration/FunctionalTests.xml`
|
- 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
|
## Creating new extensions with automated tests
|
||||||
|
|
||||||
For creating new extensions, I recommend taking
|
For creating new extensions, I recommend taking
|
||||||
|
|
28
Tests/Acceptance/StarterCest.php
Normal file
28
Tests/Acceptance/StarterCest.php
Normal 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)');
|
||||||
|
}
|
||||||
|
}
|
26
Tests/Acceptance/_support/AcceptanceTester.php
Normal file
26
Tests/Acceptance/_support/AcceptanceTester.php
Normal 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
|
||||||
|
*/
|
||||||
|
}
|
10
Tests/Acceptance/_support/Helper/Acceptance.php
Normal file
10
Tests/Acceptance/_support/Helper/Acceptance.php
Normal 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
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
2
Tests/Acceptance/_support/_generated/.gitignore
vendored
Normal file
2
Tests/Acceptance/_support/_generated/.gitignore
vendored
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
*
|
||||||
|
!.gitignore
|
41
codeception.yml
Normal file
41
codeception.yml
Normal 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"]
|
|
@ -36,6 +36,8 @@
|
||||||
"helhum/typo3-composer-setup": "^0.5.1",
|
"helhum/typo3-composer-setup": "^0.5.1",
|
||||||
"helmich/typo3-typoscript-lint": "^1.4.4",
|
"helmich/typo3-typoscript-lint": "^1.4.4",
|
||||||
"nimut/testing-framework": "^3.0",
|
"nimut/testing-framework": "^3.0",
|
||||||
|
"codeception/codeception": "^2.4",
|
||||||
|
"enm1989/chromedriver": "^2.38",
|
||||||
"roave/security-advisories": "dev-master"
|
"roave/security-advisories": "dev-master"
|
||||||
},
|
},
|
||||||
"replace": {
|
"replace": {
|
||||||
|
|
Loading…
Reference in a new issue