Disclaimers:
- I'm hoping this will help you understand so you can help us improve our documentation.
- This is simplified version, i'm ignoring some details which are unimportant for discusing this.
1/ A Moodle instance running on a webserver which you can connect to, just like you use for development and manual testing. One requirement we put on behat is that this runs on a different wwwroot to your 'normal' moodle install. So you will need to configure apache to listen on two urls for the same moodle checkout if you want to run tests manually. e.g.
$CFG->wwwroot = 'http://dan.moodle.local/' $CFG->behat_wwwroot = 'http://127.0.0.1/'
2/ A seperate database prefix and dataroot (just like phpunit):
$CFG->behat_prefix = 'behat_'; $CFG->behat_dataroot = '/Users/danp/moodles/im/moodledata_behat';
2/ Selenium. Download the jar and run it.
3/ Behat installed from composer. The admin tool will attempt to do it:
php admin/tool/behat/cli/init.php
Run the behat command which "php admin/tool/behat/cli/init.php" tells you to do:
vendor/bin/behat --config /Users/danp/moodles/pm_behating/moodledata_behat/behat/behat.yml
There tend to be three things which can stop it from working:
- Composer problems (I guess this generally works ok on windows, since phpunit doesn't seem to be plagued the same)
- Behat can't connect to selenium (How to debug - is it running, can you telnet and connect on the selenium port?)
- The selenium browser can't connect to your webserver (can you connect to your $CFG->behat_wwwroot in a browser?)
Ok, I figured it out. I thought I only had to initialise the behat environment once, but it seems like it's something I have to do every time I run the tests by changing to my moodle29 root environment in the command line and running:
php admin/tool/behat/cli/init.php
My config is as above, except I have to point $CFG->behat_wwwroot to the moodle root folder.
$CFG->wwwroot = 'http://localhost/moodle29';
$CFG->dataroot = 'C:\wamp\moodledata';
$CFG->behat_prefix = 'behat_';
$CFG->behat_dataroot = 'C:\wamp\behatdata';
$CFG->behat_wwwroot =http://127.0.0.1/moodle29 // must be different from wwwroot