Testing/Behat Testing/Running test
Running the test
Go to the terminal and cd into your code directory. If you set it up following the wiki, that will be
The command for running tests consists of a helper script which takes two arguments: the mode you want to run in and the test/s you want to run.
./test/behat/mahara_behat.sh <mode> <test/s>
The options for mode are:
- run - runs the selected tests in a local browser
- rundebug - runs the selected tests in a local browser and outputs additional debug info in the terminal
- runheadless - runs the selected tests without opening a browser
- rundebugheadless - runs the selected tests without opening a browser, but with additional debug info in the terminal
The second argument is optional. If you don't include one, all the tests will be run, but this will take a l-o-n-g time! So to only run specific tests, include a tag (e.g. @mytests) to run all the tests with that tag, or a feature file name (e.g. my_test.feature) to run the test scenarios in that file.
A couple of specific examples:
./test/behat/mahara_behat.sh rundebug @core_account
(runs all the tests in feature files tagged @core_account, using a browser, with debug output)
./test/behat/mahara_behat.sh runheadless change_account_settings.feature
(runs just the change_account_settings test, browserless, without additional debug info)
To run tests with html output, add the flag 'html' to your test run command, e.g:
./test/behat/mahara_behat.sh run create_page.feature html
When you run the command it will start up the following:
Selenium is running Start the PHP server Enable test site
If you want to stop the tests at any point click inside the terminal not the browser
To see a list of all tests, cd to your Mahara directory and run:
grep -RiPoh 'Scenario:(\s+)\K(.*)$' test/
- If another test runs instead, it's because you have more than one test tagged with the tag you are trying to run.
- The step that the test is failing on will show red or orange.
- When it fails, go to the text editor and fix the step that it broke on and run it again.