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