You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
44
50
45
51
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.
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:
60
68
61
-
```yaml
69
+
{% highlight yaml %}
70
+
62
71
config:
63
72
PhpBrowser:
64
73
url: 'http://myappurl.local'
65
-
```
74
+
75
+
{% endhighlight %}
66
76
67
77
After we configured URL we can run this test with `run` command:
That was a very simple test that you can reproduce for your own site.
117
135
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
139
157
140
158
Tests can be started with the `run` command.
141
159
142
-
```bash
160
+
{% highlight bash %}
161
+
143
162
$ php codecept.phar run
144
-
```
163
+
164
+
{% endhighlight %}
145
165
146
166
With the first argument you can run tests from one suite.
147
167
148
-
```bash
168
+
{% highlight bash %}
169
+
149
170
$ php codecept.phar run acceptance
150
-
```
171
+
172
+
{% endhighlight %}
151
173
152
174
To run exactly one test, add a second argument. Provide a local path to the test, from the suite directory.
153
175
154
-
```bash
176
+
{% highlight bash %}
177
+
155
178
$ php codecept.phar run acceptance SigninCept.php
156
-
```
179
+
180
+
{% endhighlight %}
157
181
158
182
Alternatively you can provide full path to test file:
159
183
160
-
```bash
184
+
{% highlight bash %}
185
+
161
186
$ php codecept.phar run tests/acceptance/SigninCept.php
162
-
```
187
+
188
+
{% endhighlight %}
163
189
164
190
You can provide a directory path as well:
165
191
166
-
```bash
192
+
{% highlight bash %}
193
+
167
194
$ php codecept.phar run tests/acceptance/backend
168
-
```
195
+
196
+
{% endhighlight %}
169
197
170
198
Which will execute all tests from backend dir.
171
199
@@ -175,17 +203,21 @@ To execute a group of tests that are not stored in the same dir you can organize
175
203
176
204
To generate JUnit XML output you can provide `--xml` option, and `--html` for HTML report.
177
205
178
-
```bash
206
+
{% highlight bash %}
207
+
179
208
$ php codecept.phar run --steps --xml --html
180
-
```
209
+
210
+
{% endhighlight %}
181
211
182
212
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.
0 commit comments