Actions

Testing Area/Behat Testing/Running test

From Mahara Wiki

< Testing Area‎ | Behat Testing
Revision as of 17:19, 28 Haziran 2017 by Rebeccablundell (talk | contribs)

Running the test

Go to the terminal and cd into your code directory. If you set it up following the wiki, that will be

 cd code/mahara

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
debug - 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 restrict 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 in a browser you can see 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

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

 Crtl+c

To see a list of all tests, cd to your Mahara directory and run:

grep -RiPoh 'Scenario:(\s+)\K(.*)$' test/

Test failing

  • 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.