Skip to content

Commit 40df2ef

Browse files
committed
auto updated documentation
1 parent 3bb4a44 commit 40df2ef

Some content is hidden

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

44 files changed

+2897
-1450
lines changed

docs/01-Introduction.md

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,15 +27,17 @@ Please, note that **any web site** can be covered with acceptance tests. Even if
2727

2828
#### Sample acceptance test
2929

30-
```php
30+
{% highlight php %}
31+
3132
<?php
3233
$I = new AcceptanceTester($scenario);
3334
$I->amOnPage('/');
3435
$I->click('Sign Up');
3536
$I->submitForm('#signup', array('username' => 'MilesDavis', 'email' => 'miles@davis.com'));
3637
$I->see('Thank you for Signing Up!');
3738
?>
38-
```
39+
40+
{% endhighlight %}
3941

4042
#### Pros
4143

@@ -61,7 +63,8 @@ For functional tests your application should be prepared to be run in a test env
6163

6264
#### Sample functional test
6365

64-
```php
66+
{% highlight php %}
67+
6568
<?php
6669
$I = new FunctionalTester($scenario);
6770
$I->amOnPage('/');
@@ -71,7 +74,8 @@ $I->see('Thank you for Signing Up!');
7174
$I->seeEmailSent('miles@davis.com', 'Thank you for registration');
7275
$I->seeInDatabase('users', array('email' => 'miles@davis.com'));
7376
?>
74-
```
77+
78+
{% endhighlight %}
7579

7680
#### Pros
7781

@@ -96,7 +100,8 @@ But Codeception provides some good tools to make your unit tests simpler and cle
96100

97101
#### Sample integration test
98102

99-
```php
103+
{% highlight php %}
104+
100105
<?php
101106
function testSavingUser()
102107
{
@@ -108,7 +113,8 @@ function testSavingUser()
108113
$this->unitTester->seeInDatabase('users',array('name' => 'Miles', 'surname' => 'Davis'));
109114
}
110115
?>
111-
```
116+
117+
{% endhighlight %}
112118

113119
#### Pros
114120

docs/02-GettingStarted.md

Lines changed: 64 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,11 @@ Actor classes are not written but generated from suite configuration. When you c
1717

1818
If Actor classes are not created or updated as you expect, try to generate them manually with `build` command:
1919

20-
```bash
20+
{% highlight bash %}
21+
2122
$ php codecept.phar build
22-
```
23+
24+
{% endhighlight %}
2325

2426

2527
## Writing a Sample Scenario
@@ -30,21 +32,26 @@ Let's say, we created a file `tests/acceptance/SigninCept.php`
3032

3133
We can do that by running command:
3234

33-
```bash
35+
{% highlight bash %}
36+
3437
$ php codecept.phar generate:cept acceptance Signin
35-
```
3638

37-
```php
39+
{% endhighlight %}
40+
41+
{% highlight php %}
42+
3843
<?php
3944
$I = new AcceptanceTester($scenario);
4045
?>
41-
```
46+
47+
{% endhighlight %}
4248

4349
A Scenario always starts with Actor class initialization. After that, writing a scenario is just like typing `$I->` and choosing a proper action from the auto-completion list.
4450

4551
Let's sign in to our site. We assume that we have a 'login' page where we are getting authenticated by login and password. Then we are moved to a user page, where we see the text `Hello, %username%`. Let's look at how this scenario is written in Codeception.
4652

47-
```php
53+
{% highlight php %}
54+
4855
<?php
4956
$I = new AcceptanceTester($scenario);
5057
$I->wantTo('log in as regular user');
@@ -54,25 +61,31 @@ $I->fillField('Password','qwerty');
5461
$I->click('Login');
5562
$I->see('Hello, davert');
5663
?>
57-
```
64+
65+
{% endhighlight %}
5866

5967
Before we execute this test, we should make sure that the site is running on a local web server. Let's open the `tests/acceptance.suite.yml` file and replace the URL with the URL of your web application:
6068

61-
``` yaml
69+
{% highlight yaml %}
70+
6271
config:
6372
PhpBrowser:
6473
url: 'http://myappurl.local'
65-
```
74+
75+
{% endhighlight %}
6676

6777
After we configured URL we can run this test with `run` command:
6878

69-
``` bash
79+
{% highlight bash %}
80+
7081
$ php codecept.phar run
71-
```
82+
83+
{% endhighlight %}
7284

7385
Here is the output we should see:
7486

75-
``` bash
87+
{% highlight bash %}
88+
7689
Acceptance Tests (1) -------------------------------
7790
Trying log in as regular user (SigninCept.php) Ok
7891
----------------------------------------------------
@@ -86,17 +99,21 @@ Unit Tests (0) -------------------------------------
8699
Time: 1 second, Memory: 21.00Mb
87100

88101
OK (1 test, 1 assertions)
89-
```
102+
103+
{% endhighlight %}
90104

91105
Let's get a detailed output:
92106

93-
```bash
107+
{% highlight bash %}
108+
94109
$ php codecept.phar run acceptance --steps
95-
```
110+
111+
{% endhighlight %}
96112

97113
We should see a step-by-step report on the performed actions.
98114

99-
```bash
115+
{% highlight bash %}
116+
100117
Acceptance Tests (1) -------------------------------
101118
Trying to log in as regular user (SigninCept.php)
102119
Scenario:
@@ -111,7 +128,8 @@ Scenario:
111128
Time: 0 seconds, Memory: 21.00Mb
112129

113130
OK (1 test, 1 assertions)
114-
```
131+
132+
{% endhighlight %}
115133

116134
That was a very simple test that you can reproduce for your own site.
117135
By emulating the user's actions you can test all of your site the same way.
@@ -139,33 +157,43 @@ Codeception has a global configuration in `codeception.yml` and a config for eac
139157

140158
Tests can be started with the `run` command.
141159

142-
```bash
160+
{% highlight bash %}
161+
143162
$ php codecept.phar run
144-
```
163+
164+
{% endhighlight %}
145165

146166
With the first argument you can run tests from one suite.
147167

148-
```bash
168+
{% highlight bash %}
169+
149170
$ php codecept.phar run acceptance
150-
```
171+
172+
{% endhighlight %}
151173

152174
To run exactly one test, add a second argument. Provide a local path to the test, from the suite directory.
153175

154-
```bash
176+
{% highlight bash %}
177+
155178
$ php codecept.phar run acceptance SigninCept.php
156-
```
179+
180+
{% endhighlight %}
157181

158182
Alternatively you can provide full path to test file:
159183

160-
```bash
184+
{% highlight bash %}
185+
161186
$ php codecept.phar run tests/acceptance/SigninCept.php
162-
```
187+
188+
{% endhighlight %}
163189

164190
You can provide a directory path as well:
165191

166-
```bash
192+
{% highlight bash %}
193+
167194
$ php codecept.phar run tests/acceptance/backend
168-
```
195+
196+
{% endhighlight %}
169197

170198
Which will execute all tests from backend dir.
171199

@@ -175,17 +203,21 @@ To execute a group of tests that are not stored in the same dir you can organize
175203

176204
To generate JUnit XML output you can provide `--xml` option, and `--html` for HTML report.
177205

178-
```bash
206+
{% highlight bash %}
207+
179208
$ php codecept.phar run --steps --xml --html
180-
```
209+
210+
{% endhighlight %}
181211

182212
This command will run all tests for all suites, displaying the steps, and building HTML and XML reports. Reports will be store in `tests/_output/` directory.
183213

184214
And to learn all available options:
185215

186-
```bash
216+
{% highlight bash %}
217+
187218
$ php codecept.phar help run
188-
```
219+
220+
{% endhighlight %}
189221

190222
## Debugging
191223

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