Skip to content

Commit 72523c2

Browse files
committed
Merge branch 'master' of github.com:Codeception/codeception.github.com
2 parents 36b593e + 652b7b2 commit 72523c2

17 files changed

Lines changed: 414 additions & 236 deletions

_includes/extensions.md

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -124,6 +124,53 @@ On each execution failed tests are logged and saved into `tests/_output/failed`
124124

125125

126126

127+
## RunProcess
128+
129+
[See Source](https://github.com/Codeception/Codeception/blob/2.3/ext/RunProcess.php)
130+
131+
Extension to start and stop processes per suite.
132+
Can be used to start/stop selenium server, chromedriver, phantomjs, mailcatcher, etc.
133+
134+
Can be configured in suite config:
135+
136+
```yaml
137+
# acceptance.suite.yml
138+
extensions:
139+
enabled:
140+
- Codeception\Extension\RunProcess:
141+
- chromedriver
142+
```
143+
144+
Multiple parameters can be passed as array:
145+
146+
```yaml
147+
# acceptance.suite.yml
148+
149+
extensions:
150+
enabled:
151+
- Codeception\Extension\RunProcess:
152+
- php -S 127.0.0.1:8000 -t tests/data/app
153+
- java -jar ~/selenium-server.jar
154+
```
155+
156+
In the end of a suite all launched processes will be stopped.
157+
158+
To wait for the process to be launched use `sleep` option.
159+
In this case you need configuration to be specified as object:
160+
161+
```yaml
162+
extensions:
163+
enabled:
164+
- Codeception\Extension\RunProcess:
165+
0: java -jar ~/selenium-server.jar
166+
1: mailcatcher
167+
sleep: 5 # wait 5 seconds for processes to boot
168+
```
169+
170+
HINT: you can use different configurations per environment.
171+
172+
173+
127174
## SimpleReporter
128175

129176
[See Source](https://github.com/Codeception/Codeception/blob/2.3/ext/SimpleReporter.php)

builds.markdown

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ title: Codeception Builds
77
## 2.3
88
*Requires: PHP 5.4 and higher + CURL*
99

10-
* **[Download Latest 2.3 Release](http://codeception.com/releases/2.3.3/codecept.phar)**
10+
* **[Download Latest 2.3 Release](http://codeception.com/releases/2.3.4/codecept.phar)**
11+
* [2.3.4](http://codeception.com/releases/2.3.4/codecept.phar), [for PHP 5.4 - 5.6](http://codeception.com/releases/2.3.4/php54/codecept.phar)
1112
* [2.3.3](http://codeception.com/releases/2.3.3/codecept.phar), [for PHP 5.4 - 5.6](http://codeception.com/releases/2.3.3/php54/codecept.phar)
1213
* [2.3.2](http://codeception.com/releases/2.3.2/codecept.phar), [for PHP 5.4 - 5.6](http://codeception.com/releases/2.3.2/php54/codecept.phar)
1314
* [2.3.1](http://codeception.com/releases/2.3.1/codecept.phar), [for PHP 5.4 - 5.6](http://codeception.com/releases/2.3.1/php54/codecept.phar)

changelog.markdown

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

88
# Changelog
99

10+
#### 2.3.4
11+
12+
* Added `@prepare` annotation to make realtime configuration for tests in Cest and Test classes. [See documentation](http://codeception.com/docs/06-ModulesAndHelpers#Runtime-Configuration-of-a-Test).
13+
14+
Example: disabling Doctrine2 database transaction for a test
15+
16+
```php
17+
<?php
18+
/**@prepare disableTransactions */
19+
function testDoctrine()
20+
{
21+
}
22+
23+
protected function disableTransactions(Doctrine2 $module)
24+
{
25+
$module->_reconfigure(['cleanup' => false]);
26+
}
27+
```
28+
* **[WebDriver]** **SmartWait**. Automatically waits for a few extra seconds for element to appear on a page before failing. Can reduce high usage of `wait*` methods. [See Documentation](http://codeception.com/docs/03-AcceptanceTests#SmartWait)
29+
* Added [RunProcess extension](http://codeception.com/extensions#RunProcess). Use it to start/stop Selenium (or other process) automatically for a test suite.
30+
* **[WebDriver]** Customization improvements:
31+
* added `start` option to disable autostart of a browser for tests. (can be useful for Cloud testing setups)
32+
* added `_capabilities` method for setting desired capabilities in runtime (can be combined with `@prepare` annotation)
33+
* `_initializeSession` and `_closeSession` can be used in Helpers to start and stop browser manually (combine with `start: false` config)
34+
* Fixed running a single test from a global config when using included configs. See [#4366](https://github.com/Codeception/Codeception/issues/4366) by **[zebraf1](https://github.com/zebraf1)** (improves PhpStorm integration)
35+
* [Doctrine2][Laravel5][Yii2][Phalcon] Print debug information for started/stopped transactions in tests. See [#4352](https://github.com/Codeception/Codeception/issues/4352)
36+
* [PhpBrowser][Frameworks] click with context respects base tag [#4330](https://github.com/Codeception/Codeception/issues/4330) by **[Naktibalda](https://github.com/Naktibalda)**.
37+
* **[Yii2]** Split `cleanup` configuration option (backward-compatible): ([#4379](https://github.com/Codeception/Codeception/issues/4379) by **[leandrogehlen](https://github.com/leandrogehlen)**)
38+
* `cleanup` - to cleanup loaded fixtures
39+
* `transaction` - wrap tes into transaction
40+
* **[Asserts]** Added `assertStringStartsWith` and `assertArraySubset` by **[guidocella](https://github.com/guidocella)**
41+
* **[Db]** Added `updateInDatabase` method by **[eXorus](https://github.com/eXorus)**. See [#4385](https://github.com/Codeception/Codeception/issues/4385)
42+
* In helpers and modules to check `$module::$excludeActions` property for existence before accessing it. Fixes [#4381](https://github.com/Codeception/Codeception/issues/4381) by **[CactusCoder](https://github.com/CactusCoder)**
43+
* **[Symfony]** Fixed printing debug response when `Symfony::extractRawRoles()` failed on security collector (Symfony >= 3.3) [#4309](https://github.com/Codeception/Codeception/issues/4309) by **[Basster](https://github.com/Basster)**
44+
* **[Laravel5]** Fixed bug with `disable_exception_handling` functionality. See [#4370](https://github.com/Codeception/Codeception/issues/4370). By **[janhenkgerritsen](https://github.com/janhenkgerritsen)**
45+
* **[Db]** Added `grabColumnFromDatabase` to fetches values from the column in database. By **[RebOOter](https://github.com/RebOOter)**
46+
1047
#### 2.3.3
1148

1249
* Fixed running with `--coverage`, `--xml`, `--html` options without parameters (Symfony Console 3.3 compatibility).

codecept.phar

75.2 KB
Binary file not shown.

docs/01-Introduction.md

Lines changed: 9 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ Out of the box you have tools for writing unit, functional, and acceptance tests
2323

2424
| | Codeception Unit Tests | Codeception Functional Tests | Codeception Acceptance Tests
2525
| --- | --- | --- | --- |
26-
| Scope of the test | Single PHP class | PHP Framework (Routing, Controllers, etc.) | Page in real browser |
27-
| Testing computer needs access to PHP files | Yes | Yes | No |
28-
| JavaScript | No | No | Yes |
26+
| Scope of the test | Single PHP class | PHP Framework (Routing, Controllers, etc.) | Page in browser (Chrome, Firefox, or PhpBrowser) |
27+
| Testing computer needs access to project's PHP files | Yes | Yes | No |
2928
| Webserver required | No | No | Yes |
30-
| Separate installations required | None | None | Selenium Server or PhantomJS |
29+
| JavaScript | No | No | Yes |
30+
| Additional software required | None | None | <ul><li>For WebDriver: Selenium Server or PhantomJS (deprecated)</li><li>For PhpBrowser: None</li></ul> |
3131
| Test execution speed | High | High | Low |
3232
| Configuration file | `unit.suite.yml` | `functional.suite.yml` | `acceptance.suite.yml` |
3333

@@ -40,14 +40,14 @@ Let's review those three testing types in reverse order.
4040
### Acceptance Tests
4141

4242
How does your client, manager, tester, or any other non-technical person know your website is working?
43-
By opening the browser, accessing a site, clicking on links, filling in the forms,
44-
and actually seeing the content on a web page. They have no idea of the framework, database, web-server,
45-
or programming language you use or why the application did not behave as expected.
43+
By opening the browser, accessing the site, clicking on links, filling in the forms,
44+
and actually seeing the content on a web page. They have no idea of the programming language, framework, database, web-server,
45+
or why the application did (or did not) behave as expected.
4646

47-
Acceptance tests can cover standard but complex scenarios from a user's perspective.
47+
This is what acceptance tests are doing. They cover scenarios from a user's perspective.
4848
With acceptance tests, you can be confident that users, following all the defined scenarios, won't get errors.
4949

50-
Please note that **any website** can be covered with acceptance tests, even if you use a very custom CMS or framework.
50+
**Any website** can be covered with acceptance tests, even if you use a very exotic CMS or framework.
5151

5252
#### Sample acceptance test
5353

@@ -62,19 +62,6 @@ $I->see('Thank you for Signing Up!');
6262

6363
{% endhighlight %}
6464

65-
#### Pros
66-
67-
* can be run on any website
68-
* can test JavaScript and AJAX requests
69-
* can be shown to your clients and managers
70-
* most stable in support: less affected by changes in source code or technologies
71-
72-
#### Cons
73-
* the slowest: requires running browser and database repopulation
74-
* fewer checks can lead to false-positive results
75-
* not stable in execution: rendering and JavaScript issues can lead to unpredictable results
76-
77-
7865
### Functional Tests
7966

8067
What if we could check our application without running it on a server?
@@ -103,19 +90,6 @@ $I->seeInDatabase('users', ['email' => 'miles@davis.com']);
10390

10491
{% endhighlight %}
10592

106-
#### Pros
107-
108-
* like acceptance tests, but much faster
109-
* can provide more detailed reports
110-
* you can still show this code to managers and clients
111-
* stable enough: only major code changes, or moving to other framework, can break them
112-
113-
#### Cons
114-
115-
* JavaScript and AJAX can't be tested
116-
* by emulating the browser you might get more false-positive results
117-
* requires a framework
118-
11993
### Unit Tests
12094

12195
Testing pieces of code before coupling them together is highly important as well. This way,
@@ -147,19 +121,6 @@ function testSavingUser()
147121

148122
{% endhighlight %}
149123

150-
#### Pros
151-
152-
* fastest (well, in the current example, you still need database repopulation because it's an integration test,
153-
not a pure unit test)
154-
* can cover rarely used features
155-
* can test the stability of the application core
156-
* fundamental for any developer
157-
158-
#### Cons
159-
160-
* doesn't test connections between units
161-
* unstable in support: very sensitive to code changes
162-
163124
## Conclusion
164125

165126
Despite the wide popularity of *TDD* (Test Driven Development), some PHP developers never write automated tests for their applications mostly because they think it's hard, slow or boring.

docs/02-GettingStarted.md

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,47 @@ and bootstrapped your first test suites. Codeception has generated three of them
1010
They are well described in the [previous chapter](http://codeception.com/docs/01-Introduction). Inside your __/tests__ folder you will have three `.yml` config files and three directories
1111
with names corresponding to these suites: `unit`, `functional`, `acceptance`. Suites are independent groups of tests with a common purpose.
1212

13+
## The Codeception Syntax
14+
15+
Codeception follows simple naming rules to make it easy to remember (as well as easy to understand) its method names.
16+
17+
* **Actions** start with a plain english verb, like "click" or "fill". Examples:
18+
{% highlight php %}
19+
20+
<?php
21+
$I->click('Login');
22+
$I->fillField('#input-username', 'John Dough');
23+
$i->pressKey('#input-remarks', 'foo');
24+
25+
{% endhighlight %}
26+
* **Assertions** always start with "see" or "dontSee". Examples:
27+
{% highlight php %}
28+
29+
<?php
30+
$I->see('Welcome');
31+
$I->seeInTitle('My Company');
32+
$i->seeElement('nav');
33+
$i->dontSeeElement('#error-message');
34+
$i->dontSeeInPageSource('<section class="foo">');
35+
36+
{% endhighlight %}
37+
* **Grabbers** just *read* something from the page, but don't process it. The return value of those are meant to be saved as variables and used later. Example:
38+
{% highlight php %}
39+
40+
<?php
41+
$method = $I->grabAttributeFrom('#login-form', 'method');
42+
$I->assertEquals('post', $method);
43+
44+
{% endhighlight %}
45+
1346
## Actors
1447

1548
One of the main concepts of Codeception is representation of tests as actions of a person.
1649
We have a UnitTester, who executes functions and tests the code. We also have a FunctionalTester, a qualified tester,
1750
who tests the application as a whole, with knowledge of its internals. Lastly we have an AcceptanceTester, a user who works with our application
1851
through an interface that we provide.
1952

20-
Actor classes are not written but generated from suite configuration. **Methods of actor classes are generally taken from [Codeception Modules](http://codeception.com/docs/06-ModulesAndHelpers)**.
53+
**Methods of actor classes are generally taken from [Codeception Modules](http://codeception.com/docs/06-ModulesAndHelpers)**.
2154
Each module provides predefined actions for different testing purposes, and they can be combined to fit the testing environment.
2255
Codeception tries to solve 90% of possible testing issues in its modules, so you don't have to reinvent the wheel.
2356
We think that you can spend more time on writing tests and less on writing support code to make those tests run.

0 commit comments

Comments
 (0)