Skip to content

Commit e4b93c3

Browse files
committed
auto updated documentation
1 parent 0aa6825 commit e4b93c3

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+869
-7369
lines changed

_includes/extensions.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
## DotReporter
44

5-
[See Source](https://github.com/Codeception/Codeception/blob/2.5/ext/DotReporter.php)
5+
[See Source](https://github.com/Codeception/Codeception/blob/3.0/ext/DotReporter.php)
66

77
DotReporter provides less verbose output for test execution.
88
Like PHPUnit printer it prints dots "." for successful testes and "F" for failures.
@@ -38,7 +38,7 @@ Use this extension as an example for building custom reporters.
3838

3939
## Logger
4040

41-
[See Source](https://github.com/Codeception/Codeception/blob/2.5/ext/Logger.php)
41+
[See Source](https://github.com/Codeception/Codeception/blob/3.0/ext/Logger.php)
4242

4343
Log suites/tests/steps using Monolog library.
4444
Monolog should be installed additionally by Composer.
@@ -65,7 +65,7 @@ extensions:
6565

6666
## Recorder
6767

68-
[See Source](https://github.com/Codeception/Codeception/blob/2.5/ext/Recorder.php)
68+
[See Source](https://github.com/Codeception/Codeception/blob/3.0/ext/Recorder.php)
6969

7070
Saves a screenshot of each step in acceptance tests and shows them as a slideshow on one HTML page (here's an [example](http://codeception.com/images/recorder.gif))
7171
Activated only for suites with WebDriver module enabled.
@@ -91,6 +91,7 @@ extensions:
9191
* `failure_color` (default: danger) - bootstrap values to be used for color representation for failed tests
9292
* `error_color` (default: dark) - bootstrap values to be used for color representation for scenarios where there's an issue occurred while generating a recording
9393
* `delete_orphaned` (default: false) - delete recording folders created via previous runs
94+
* `include_microseconds` (default: false) - enable microsecond precision for recorded step time details
9495

9596
#### Examples:
9697

@@ -123,7 +124,7 @@ public function testLogin(AcceptanceTester $I)
123124

124125
## RunBefore
125126

126-
[See Source](https://github.com/Codeception/Codeception/blob/2.5/ext/RunBefore.php)
127+
[See Source](https://github.com/Codeception/Codeception/blob/3.0/ext/RunBefore.php)
127128

128129
Extension for execution of some processes before running tests.
129130

@@ -154,7 +155,7 @@ HINT: you can use different configurations per environment.
154155

155156
## RunFailed
156157

157-
[See Source](https://github.com/Codeception/Codeception/blob/2.5/ext/RunFailed.php)
158+
[See Source](https://github.com/Codeception/Codeception/blob/3.0/ext/RunFailed.php)
158159

159160
Saves failed tests into tests/log/failed in order to rerun failed tests.
160161

@@ -183,7 +184,7 @@ On each execution failed tests are logged and saved into `tests/_output/failed`
183184

184185
## RunProcess
185186

186-
[See Source](https://github.com/Codeception/Codeception/blob/2.5/ext/RunProcess.php)
187+
[See Source](https://github.com/Codeception/Codeception/blob/3.0/ext/RunProcess.php)
187188

188189
Extension to start and stop processes per suite.
189190
Can be used to start/stop selenium server, chromedriver, phantomjs, mailcatcher, etc.
@@ -230,7 +231,7 @@ HINT: you can use different configurations per environment.
230231

231232
## SimpleReporter
232233

233-
[See Source](https://github.com/Codeception/Codeception/blob/2.5/ext/SimpleReporter.php)
234+
[See Source](https://github.com/Codeception/Codeception/blob/3.0/ext/SimpleReporter.php)
234235

235236
This extension demonstrates how you can implement console output of your own.
236237
Recommended to be used for development purposes only.

_includes/modules.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
<li><a href="/docs/modules/AMQP">AMQP</a></li><li><a href="/docs/modules/PhpBrowser">PhpBrowser</a></li><li><a href="/docs/modules/AngularJS">AngularJS</a></li><li><a href="/docs/modules/Queue">Queue</a></li><li><a href="/docs/modules/Apc">Apc</a></li><li><a href="/docs/modules/REST">REST</a></li><li><a href="/docs/modules/Asserts">Asserts</a></li><li><a href="/docs/modules/Redis">Redis</a></li><li><a href="/docs/modules/Cli">Cli</a></li><li><a href="/docs/modules/SOAP">SOAP</a></li><li><a href="/docs/modules/DataFactory">DataFactory</a></li><li><a href="/docs/modules/Sequence">Sequence</a></li><li><a href="/docs/modules/Db">Db</a></li><li><a href="/docs/modules/Silex">Silex</a></li><li><a href="/docs/modules/Doctrine2">Doctrine2</a></li><li><a href="/docs/modules/Symfony">Symfony</a></li><li><a href="/docs/modules/FTP">FTP</a></li><li><a href="/docs/modules/WebDriver">WebDriver</a></li><li><a href="/docs/modules/Facebook">Facebook</a></li><li><a href="/docs/modules/XMLRPC">XMLRPC</a></li><li><a href="/docs/modules/Filesystem">Filesystem</a></li><li><a href="/docs/modules/Yii1">Yii1</a></li><li><a href="/docs/modules/Laravel5">Laravel5</a></li><li><a href="/docs/modules/Yii2">Yii2</a></li><li><a href="/docs/modules/Lumen">Lumen</a></li><li><a href="/docs/modules/ZF1">ZF1</a></li><li><a href="/docs/modules/Memcache">Memcache</a></li><li><a href="/docs/modules/ZF2">ZF2</a></li><li><a href="/docs/modules/MongoDb">MongoDb</a></li><li><a href="/docs/modules/ZendExpressive">ZendExpressive</a></li><li><a href="/docs/modules/Phalcon">Phalcon</a></li>
1+
<li><a href="/docs/modules/AMQP">AMQP</a></li><li><a href="/docs/modules/Phalcon">Phalcon</a></li><li><a href="/docs/modules/Apc">Apc</a></li><li><a href="/docs/modules/PhpBrowser">PhpBrowser</a></li><li><a href="/docs/modules/Asserts">Asserts</a></li><li><a href="/docs/modules/Queue">Queue</a></li><li><a href="/docs/modules/Cli">Cli</a></li><li><a href="/docs/modules/REST">REST</a></li><li><a href="/docs/modules/DataFactory">DataFactory</a></li><li><a href="/docs/modules/Redis">Redis</a></li><li><a href="/docs/modules/Db">Db</a></li><li><a href="/docs/modules/SOAP">SOAP</a></li><li><a href="/docs/modules/Doctrine2">Doctrine2</a></li><li><a href="/docs/modules/Sequence">Sequence</a></li><li><a href="/docs/modules/FTP">FTP</a></li><li><a href="/docs/modules/Symfony">Symfony</a></li><li><a href="/docs/modules/Filesystem">Filesystem</a></li><li><a href="/docs/modules/WebDriver">WebDriver</a></li><li><a href="/docs/modules/Laravel5">Laravel5</a></li><li><a href="/docs/modules/Yii2">Yii2</a></li><li><a href="/docs/modules/Lumen">Lumen</a></li><li><a href="/docs/modules/ZF2">ZF2</a></li><li><a href="/docs/modules/Memcache">Memcache</a></li><li><a href="/docs/modules/ZendExpressive">ZendExpressive</a></li><li><a href="/docs/modules/MongoDb">MongoDb</a></li>

changelog.markdown

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,32 @@ title: Codeception Changelog
77

88
# Changelog
99

10+
#### 3.0.0
11+
12+
* **BREAKING** Modules removed:
13+
* Yii1
14+
* XMLRPC
15+
* AngularJS
16+
* Silex
17+
* Facebook
18+
* ZF1
19+
* **POSSIBLE BREAKING** PHPUnit 8.x support.
20+
> Upgrade Notice: If you face issues with conflicting PHPUnit classes or difference in method signatures, lock version for PHPUnit in composer.json: “phpunit/phpunit”:”^7.0.0”
21+
* **BREAKING** Multi-session testing disabled by default. Add `use \Codeception\Lib\Actor\Shared\Friend;` to enable `$I->haveFriend`.
22+
* **BREAKING** **[WebDriver]** `pauseExecution` removed in favor of `$I->pause()`
23+
* [Interactive pause](https://codeception.com/docs/02-GettingStarted#Interactive-Pause) inside tests with `$I->pause();` command in debug mode added. Allows to write and debug test in realtime.
24+
* Introduced [Step Decorators](https://codeception.com/docs/08-Customization#Step-Decorators) - auto-generated actions around module and helper methods. As part of this feature implemented
25+
* [Conditional Assertions](https://codeception.com/docs/03-AcceptanceTests#Conditional-Assertions) (`$I->canSee()`)
26+
* [Retries](https://codeception.com/docs/03-AcceptanceTests#Retry) (`$I->retryClick()`);
27+
* [Silent Actions](https://codeception.com/docs/03-AcceptanceTests#A-B-Testing)(`$I->tryToClick`).
28+
* Print artifacts on test failure
29+
* **[REST]** Short API responses in debug mode with `shortDebugResponse` config option. See [#5455](https://github.com/Codeception/Codeception/issues/5455) by **[sebastianneubert](https://github.com/sebastianneubert)**
30+
* **[WebDriver]** `switchToIFrame` allow to locate iframe by CSS/XPath.
31+
* [PhpBrowser][Frameworks] clickButton throws exception if button is outside form by **[Naktibalda](https://github.com/Naktibalda)**.
32+
* Updated to PHP 7.3 in Docker container by **[OneEyedSpaceFish](https://github.com/OneEyedSpaceFish)**
33+
* Recorder Extension: Added timestamp information with `include_microseconds` config option. By **[OneEyedSpaceFish](https://github.com/OneEyedSpaceFish)**.
34+
* **[REST]** Fixed sending request with duplicated slash with endpoint + URL. By **[nicholascus](https://github.com/nicholascus)**
35+
* **[Db]** Remove generateWhereClause method from SqlSrv to be compatible with other drivers. By **[Naktibalda](https://github.com/Naktibalda)**
1036
#### 2.5.6
1137

1238
* **[WebDriver]** Fixed `loadSessionSnapshot` with php-webdriver 1.1.3 by **[Naktibalda](https://github.com/Naktibalda)**.

docs/02-GettingStarted.md

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -267,6 +267,55 @@ class TaskCrudCest
267267

268268
Learn more about the [Cest format](http://codeception.com/docs/07-AdvancedUsage#Cest-Classes) in the Advanced Testing section.
269269

270+
## Interactive Pause
271+
272+
It's hard to write a complete test at once.
273+
You will need to try different commands with different arguments before you find a correct path.
274+
275+
Since Codeception 3.0 you can pause execution in any point and enter interactive shell where you will be able to try commands in action.
276+
All you need to do is to **call `$I->pause()` in debug mode**.
277+
278+
{% highlight php %}
279+
280+
<?php
281+
// use pause inside a test:
282+
$I->pause();
283+
284+
{% endhighlight %}
285+
286+
When a test gets to this point it stops and shows a console where you can try all available commands.
287+
This can be very useful when you write functional, acceptance, or api test.
288+
289+
![](https://user-images.githubusercontent.com/220264/54929617-875ad180-4f1e-11e9-8fea-fc1b02423050.gif)
290+
291+
Inside interactive pause you can use all power of PHP interpreter. Use variables, functions, etc.
292+
Result of the last executed command (usually a grabber) is saved to `$result` variable, so you can use it in next commands.
293+
294+
Inside acceptance or functional test you can save page screenshot or html snapshot to check the page you are working on.
295+
296+
{% highlight php %}
297+
298+
<?php
299+
// inside PhpBrowser, WebDrvier, frameworks
300+
// saves current HTML and prints a path to created file
301+
$I->makeHtmlSnapshot();
302+
303+
// inside WebDriver
304+
// saves screenshot and prints a path to created file
305+
$I->makeScreenshot();
306+
307+
{% endhighlight %}
308+
309+
To try commands without running a single test you can launch interactive console:
310+
311+
{% highlight bash %}
312+
313+
$ php vendor/bin/codecept console suitename
314+
315+
{% endhighlight %}
316+
317+
Now you can execute all the commands of a corresponding Actor class and see the results immediately.
318+
270319
## BDD
271320

272321
Codeception allows execution of user stories in Gherkin format in a similar manner as is done in Cucumber or Behat.

docs/03-AcceptanceTests.md

Lines changed: 136 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,6 @@ class SigninCest
8585
{
8686
public function tryToTest(AcceptanceTester $I)
8787
{
88-
$I->wantTo('test my page');
8988
}
9089
}
9190
@@ -312,6 +311,21 @@ $I->cantSeeInField('user[name]', 'Miles');
312311

313312
Each failed assertion will be shown in the test results, but it won't stop the test.
314313

314+
Conditional assertions are disabled in bootstrap setup. To enable them you should add corresponding step decorators to suite config:
315+
316+
> If you started project as `codecept init acceptance` they should be already enabled in config
317+
318+
{% highlight yaml %}
319+
320+
# in acceptance.suite.yml
321+
# or in codeception.yml inside suites section
322+
step_drcorators:
323+
- \Codeception\Step\ConditionalAssertion
324+
325+
{% endhighlight %}
326+
327+
Then rebuild actors with `codecept build` command.
328+
315329
#### Comments
316330

317331
Within a long scenario, you should describe what actions you are going to perform and what results should be achieved.
@@ -508,8 +522,6 @@ $I->wait(3); // wait for 3 secs
508522

509523
#### SmartWait
510524

511-
*since 2.3.4 version*
512-
513525
It is possible to wait for elements pragmatically.
514526
If a test uses element which is not on a page yet, Codeception will wait for few extra seconds before failing.
515527
This feature is based on [Implicit Wait](http://www.seleniumhq.org/docs/04_webdriver_advanced.jsp#implicit-waits) of Selenium.
@@ -558,6 +570,64 @@ $I->seeNumberOfElements(['css' => 'button.link'], 5); // DISABLED, can wait only
558570

559571
{% endhighlight %}
560572

573+
#### Retry
574+
575+
When it's hard to define condition to wait for, we can retry a command few times until it succeeds.
576+
For instance, if you try to click while it's animating you can try to do it few times until it freezes.
577+
Since Codeception 3.0 each action and assertion have an alias prefixed with `retry` which allows to retry a flaky command.
578+
579+
{% highlight php %}
580+
581+
<?php
582+
$I->retryClick('flaky element');
583+
$I->retrySee('Something changed');
584+
585+
{% endhighlight %}
586+
587+
Retry can be configured via `$I->retry()` command, where you can set number of retries and interval.
588+
589+
{% highlight php %}
590+
591+
<?php
592+
// Retry up to 4 sec: 10 times, for 400ms interval
593+
$I->retry(10, 400);
594+
595+
{% endhighlight %}
596+
597+
`$I->retry` takes 2 parameters:
598+
* number of retries (1 by default)
599+
* interval (200ms by default)
600+
601+
Retries are disabled by default. To enable them you should add retry step decorators to suite config:
602+
603+
> If you started project as `codecept init acceptance` they should be already enabled in config
604+
605+
{% highlight yaml %}
606+
607+
# in acceptance.suite.yml
608+
# or in codeception.yml inside suites section
609+
step_drcorators:
610+
- \Codeception\Step\Retry
611+
612+
{% endhighlight %}
613+
614+
Then add `\Codeception\Lib\Actor\Shared\Retry` trait into `AcceptanceTester` class:
615+
616+
{% highlight php %}
617+
618+
<?php
619+
class AcceptanceTester extends \Codeception\Actor
620+
{
621+
use _generated\AcceptanceTesterActions;
622+
623+
use \Codeception\Lib\Actor\Shared\Retry;
624+
}
625+
626+
{% endhighlight %}
627+
628+
Run `codecept build` to recreate actions. New `retry*` actions are available for tests.
629+
Keep in mind, that you can change retry policy dynamically for each test.
630+
561631
#### Wait and Act
562632
563633
To combine `waitForElement` with actions inside that element you can use the [performOn](http://codeception.com/docs/modules/WebDriver#performOn) method.
@@ -588,6 +658,53 @@ $I->performOn('.confirm', function(\Codeception\Module\WebDriver $I) {
588658

589659
For more options see [`performOn()` reference](http://codeception.com/docs/modules/WebDriver#performOn).
590660

661+
#### A/B Testing
662+
663+
When a web site acts unpredictably you may need to react on that change.
664+
This happens if site configured for A/B testing, or shows different popups, based on environment.
665+
666+
Since Codeception 3.0 you can have some actions to fail silently, is they are errored.
667+
Let's say, you open a page and some times there is a popup which should be closed.
668+
We may try to hit the "close" button but if this action fails (no popup on page) we just continue the test.
669+
670+
This is how it can be implemented:
671+
672+
{% highlight php %}
673+
674+
<?php
675+
$I->amOnPage('/');
676+
$I->tryToClick('x', '.alert');
677+
// continue execution
678+
679+
{% endhighlight %}
680+
681+
You can also use `tryTo` as condition for your tests:
682+
683+
{% highlight php %}
684+
685+
<?php
686+
if ($I->tryToSeeElement('.alert')) {
687+
$I->waitForText('Do you accept cookies?');
688+
$I->click('Yes');
689+
}
690+
691+
{% endhighlight %}
692+
693+
A/B testing is disabled by default. To enable it you should add corresponding step decorators to suite config:
694+
695+
> If you started project as `codecept init acceptance` in Codeception >= 3.0 they should be already enabled in config
696+
697+
{% highlight yaml %}
698+
699+
# in acceptance.suite.yml
700+
# or in codeception.yml inside suites section
701+
step_drcorators:
702+
- \Codeception\Step\TryTo
703+
704+
{% endhighlight %}
705+
706+
Then rebuild actors with `codecept build` command.
707+
591708
### Multi Session Testing
592709

593710
Codeception allows you to execute actions in concurrent sessions. The most obvious case for this
@@ -626,6 +743,20 @@ $nickAdmin->leave();
626743

627744
{% endhighlight %}
628745

746+
Multi session testing is disabled by default. To enable it, add `\Codeception\Lib\Actor\Shared\Friend` into `AcceptancTester`.
747+
748+
{% highlight php %}
749+
750+
<?php
751+
class AcceptanceTester extends \Codeception\Actor
752+
{
753+
use _generated\AcceptanceTesterActions;
754+
755+
use \Codeception\Lib\Actor\Shared\Friend;
756+
}
757+
758+
{% endhighlight %}
759+
629760
### Cloud Testing
630761
631762
Some environments are hard to be reproduced manually, testing Internet Explorer 6-8 on Windows XP may be a hard thing,
@@ -651,22 +782,6 @@ It should be mentioned that Cloud Testing services are not free. You should inve
651782
and choose one that fits your needs. They also may work painfully slowly if ping times between the local server
652783
and the cloud is too high. This may lead to random failures in acceptance tests.
653784
654-
### AngularJS Testing
655-
656-
In the modern era of Single Page Applications, the browser replaces the server in creating the user interface.
657-
Unlike traditional web applications, web pages are not reloaded on user actions.
658-
All interactions with the server are done in JavaScript with XHR requests.
659-
However, testing Single Page Applications can be a hard task.
660-
There could be no information of the application state: e.g. has it completed rendering or not?
661-
What is possible to do in this case is to use more `wait*` methods or execute JavaScript that checks the application state.
662-
663-
For applications built with the AngularJS v1.x framework,
664-
we implemented [AngularJS module](http://codeception.com/docs/modules/AngularJS) which is based on Protractor
665-
(an official tool for testing Angular apps). Under the hood, it pauses step execution
666-
before the previous actions are completed and use the AngularJS API to check the application state.
667-
668-
The AngularJS module extends WebDriver so that all the configuration options from it are available.
669-
670785
### Debugging
671786
672787
Codeception modules can print valuable information while running.
@@ -684,9 +799,8 @@ PhpBrowser will store the HTML code and WebDriver will save a screenshot of the
684799

685800
Additional debugging features by Codeception:
686801

687-
* [pauseExecution](http://codeception.com/docs/modules/WebDriver#pauseExecution) method of WebDriver module allows pausing the test.
688-
* [Recorder extension](http://codeception.com/addons#CodeceptionExtensionRecorder) allows to record tests step-by-steps and show them in slideshow
689-
* [Interactive Console](http://codeception.com/docs/07-AdvancedUsage#Interactive-Console) is a REPL that allows to type and check commands for instant feedback.
802+
* [Interactive Pause](http://codeception.com/docs/02-GettingStarted#Interactive-Pause) is a REPL that allows to type and check commands for instant feedback.
803+
* [Recorder Extension](http://codeception.com/addons#CodeceptionExtensionRecorder) allows to record tests step-by-steps and show them in slideshow
690804

691805
### Custom Browser Sessions
692806

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy