Actions

Difference between revisions of "Testing Area/Behat Testing/Running test"

From Mahara Wiki

< Testing Area‎ | Behat Testing
Line 4: Line 4:
 
   /var/www/html/mahara
 
   /var/www/html/mahara
  
Type:
+
The command for running tests consists of a helper script which takes two arguments,
./test/behat/mahara_behat.sh rundebug @youtagthatyouwanttorun
+
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:
 
When you run the command it will start up the following:

Revision as of 17:09, 28 June 2017

Running the test

Go to the terminal and cd into:

 /var/www/html/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.