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?)
Same problem. Though I ran behat successfully on my local machine, when I tried doing the same on virtual machine get "The base URL (http://localhost/moodle) is not a behat test site, ensure you started the built-in web server in the correct directory or your web server is correctly started and set up"
Here is output for init script:
php admin/tool/behat/cli/init.php
Behat test environment already installed
Acceptance tests environment enabled on http://localhost/moodle, to run the tests use:
vendor/bin/behat --config /var/lib/sitedata/behat-moodle-site/behat/behat.yml
Here are config details for behat:
$CFG->behat_prefix = 'b_';
$CFG->behat_dataroot = '/var/lib/sitedata/behat-moodle-site';
$CFG->behat_wwwroot = 'http://localhost/moodle';
my wwwroot is different from behat_wwwroot