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
{{ message }}
This repository was archived by the owner on Dec 1, 2018. It is now read-only.
Repository navigation
Commit df21fba
Browse filesBrowse the repository at this point in the historyBrowse files
Leonid Makarov
authored
Merge pull request #142 from blinkreaction/develop
Copy file name to clipboardExpand all lines: docs/behat.md
+205-1Lines changed: 205 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ Drude expects your Behat tests to be in `tests/behat` folder of the project repo
10
10
> \_ composer.json
11
11
> \_ composer.lock
12
12
13
-
See [drude-testing](https://github.com/blinkreaction/drude-testing) repo for a good working example. This repo is used for automated tests of Drude builds.
13
+
See [Drupal 7 sample project](https://github.com/blinkreaction/drude-d7-testing) repo for a working example.
14
14
15
15
## Docker profile example
16
16
@@ -52,3 +52,207 @@ Tests can be launched with `dsh` (Drude Shell):
52
52
dsh behat
53
53
54
54
This will download composer dependencies and run behat with the docker profile.
55
+
56
+
## Behat (goutte-driver)
57
+
58
+
Basic configuration (see [behat.common.yml](https://github.com/blinkreaction/drude-d7-testing/blob/master/tests/behat/behat.common.yml)) uses goutte as the default driver. Goutte is a very basic browser emulator. It is much faster than real browsers, but also very limited. It can make HTTP requests, but does not parse CSS, execute JS or do any rendering.
59
+
60
+
Goutte can be used in many cases and does not require additional configuration/installation.
61
+
62
+
## Behat (selenium2-driver)
63
+
64
+
If your tests require javascript support, selenium2-driver should be used. You can set selenium2-driver as the default one.
65
+
Selenium2 works with real browsers, using them as zombies for testing purposes. You get a standard, feature reach, real browser, with CSS styling, JS and AJAX execution - all supported out of the box.
66
+
67
+
The easiest way to enable Selenium support is to use stock Selenium docker images.
68
+
To do this, update `docker-compose.yml` file in your project folder as follows.
69
+
70
+
```yml
71
+
# selenium2 node
72
+
# Uncomment the service definition section below and the link in the web service above to start using selenium2 driver for Behat tests requiring JS support.
73
+
browser:
74
+
hostname: browser
75
+
image: selenium/standalone-chrome
76
+
ports:
77
+
- "4444"
78
+
environment:
79
+
- DOMAIN_NAME=drude-d7-testing.browser.docker
80
+
```
81
+
82
+
You can also use Firefox image: `selenium/standalone-firefox`
83
+
84
+
After updating `docker-compose.yml` you have to tell Behat to use Selenium.
85
+
Add your selenium configuration in `behat.yml` (environment variable `DOMAIN_NAME` is used as `selenium2 wd_host`).
# Stick with chrome by default. It's 2x faster than firefox or phantomjs (your results may vary).
100
+
browser_name: chrome
101
+
Drupal\DrupalExtension:
102
+
drupal:
103
+
# Site docroot inside Drude.
104
+
drupal_root: /var/www/docroot
105
+
drush:
106
+
# Site docroot inside Drude.
107
+
root: /var/www/docroot
108
+
```
109
+
110
+
## Behat (selenium2-driver) - using VNC
111
+
112
+
If you use Selenium with a browser in a container, you can receive test screenshots but you cannot see the browser itself. Sometimes it is very useful to watch tests running in the browser (e.g. when you are creating a new test and want to see how it performs).
113
+
In such cases [VNC](https://en.wikipedia.org/wiki/Virtual_Network_Computing) can be used.
114
+
115
+
1. Install VNC client on your computer (there are many version for all platforms).
116
+
2. Update `docker-compose.yml` file in your project folder:
117
+
118
+
```yml
119
+
# selenium2 node
120
+
# Uncomment the service definition section below and the link in the web service above to start using selenium2 driver for Behat tests requiring JS support.
121
+
browser:
122
+
hostname: browser
123
+
image: selenium/standalone-chrome-debug
124
+
ports:
125
+
- "4444"
126
+
- "5900:5900"
127
+
environment:
128
+
- DOMAIN_NAME=drude-d7-testing.browser.docker
129
+
```
130
+
You have to use `selenium/standalone-chrome-debug` or `selenium/standalone-firefox-debug` images. They both include a VNC server.
131
+
Use `localhost:5900` as the host and `secret` as the password in your VNC client.
132
+
Now if you connect with the VNC client and run behat test, you will be able to see tests running in the browser inside the container.
133
+
134
+
Note: If you are working with several project concurrently, it is a good idea to have a separate port per project (e.g. `5901:5900`, `5902:5900`, etc.)
135
+
136
+
## Integration with PhpStorm
137
+
138
+
It is possible to connect PhpStorm with the `cli` container and run behat tests from within PhpStorm.
139
+
PhpStorm uses ssh to connect to and use remote interpreters and tools.
140
+
141
+
1. Add the following line in `docker-compose.yml` to expose ssh-server in the `cli`container:
142
+
143
+
```yml
144
+
cli:
145
+
...
146
+
ports:
147
+
- "2221:22"
148
+
...
149
+
```
150
+
2. Update container configuration with `dsh up`.
151
+
3. You should now be able to connect to the `cli` container via ssh. Use username `docker` and pasword `docker`:
152
+
153
+
```
154
+
ssh docker@localhost -p 2223
155
+
```
156
+
157
+
Note: If you are working with several project concurrently, it is a good idea to have a separate port per project (e.g. `2222:22`, `2223:22`, etc.)
158
+
159
+
### Add new deployment server
160
+
161
+
Open settings (menu item *File->Settings...*). In the opened window on the left side select item *Build, Execution, Deployment->Deployment*:
162
+
163
+

164
+
165
+
Create new SFTP connection and fill-out the form. Don't forget to fill-out *Web server root URL*.
166
+
Press *Test SFTP connection...* button and if everything is ok, you will see that test is successful.
167
+
168
+
On the second tab you should to check and correct mapping:
In the opened window add a new interpreter and choose **Deployment configuration** option and deployment server from select list (it should be server from previous step).
185
+
186
+
### Add Behat interpreter configuration
187
+
188
+
Open settings (menu item *File->Settings...*). In the opened window on the left side select item *Languages & Frameworks->PHP->Behat*:
0 commit comments