Skip to content
This repository has been archived by the owner on Nov 12, 2019. It is now read-only.

[FEATURE] Example acceptance tests with Codeception #31

Merged
merged 1 commit into from May 31, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
18 changes: 18 additions & 0 deletions README.md
Expand Up @@ -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
Expand Down
28 changes: 28 additions & 0 deletions Tests/Acceptance/StarterCest.php
@@ -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 changes: 26 additions & 0 deletions Tests/Acceptance/_support/AcceptanceTester.php
@@ -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 changes: 10 additions & 0 deletions Tests/Acceptance/_support/Helper/Acceptance.php
@@ -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 changes: 2 additions & 0 deletions Tests/Acceptance/_support/_generated/.gitignore
@@ -0,0 +1,2 @@
*
!.gitignore
41 changes: 41 additions & 0 deletions codeception.yml
@@ -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"]
2 changes: 2 additions & 0 deletions composer.json
Expand Up @@ -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": {
Expand Down