Automatic functional testing


How to install and run

Installation

  1. Do a normal install on the machine you wish to test on (this is so a valid configuration file is present) 
  2. Create a behat.xml file in your config directory. It should contain the following settings:

    behat.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <rogo>
      <website>http://localhost:8000/</website>
      <db_database>behat_database_schema_name</db_database>
      <db_user>username</db_user>
      <db_password>password</db_password>
      <data>path_to_behat_user_data</data>
      <faildump>path_for_screenshots_of_failures</faildump>
    </rogo>
    
  3. Run the following script: testing/behat/cli/init.php
  4. Download selenium (V3.x is supported) from http://www.seleniumhq.org/download/
  5. Download ChromeDriver from https://sites.google.com/a/chromium.org/chromedriver/

Note for Windows users

You will need to install composer.phar into the root rogo directory manually from https://getcomposer.org/download/

Running

  1. Start the webserver referenced in behat's website setting. You can use the builtin php web server with the following command: php -S localhost:8000
  2. Start Selenium with a command similar to: java -Dwebdriver.chrome.driver=<path_to_chromedriver> -jar selenium-server-standalone-<version_number>.jar
  3. Run the following command to run the test suite: vendor/bin/behat --config <rogo_root_directory>/testing/behat/config/behat.yml

Additional information

Alternative configuration

It is also possible to configure behat using the main Rogo config using the following settings:

  1. $cfg_behat_website - Should be a url and specific port, for example http://localhost:8000/
  2. $cfg_behat_db_database - Should be the name of a database schema that is different to the live schema, but on the same server
  3. $cfg_behat_data - The location that you wish behat to store user data files, must be different to the value of $cfg_rogo_data
  4. $cfg_behat_db_user - Username that can be used to fully control your database
  5. $cfg_behat_db_password - The password for the database user
Settings in the behat.xml file will override any behat settings in the main config.inc.php file.

How to install and run on Docker

  1. Start up rogo docker

    docker-compose
    docker-compose -f docker-compose.yml -f db.yml -f expose.yml -f selenium.yml up -d
  2. Install rogo
  3. Create a behat.xml file in your config directory. It should contain the following settings:

    behat.xml
    <?xml version="1.0" encoding="UTF-8"?>
    <rogo>
      <website>http://web:8003</website>
      <db_database>behat_database_schema_name</db_database>
      <db_user>username</db_user>
      <db_password>password</db_password>
      <data>path_to_behat_user_data</data>
    </rogo>
    
  4. Run the following script: testing/behat/cli/init.php on the web service.
  5. Start the webserver referenced in behat's website setting. You can use the builtin php web server with the following command: php -S localhost:8003
  6. Overwrite the generated /testing/behat/config/behat.yml file with the location of the selenium service:
behat.yml
...
...
extensions:
    Behat\MinkExtension:
      base_url: 'http://web:8003'
      goutte: null
      selenium2:
        browser: chrome
        wd_host: 'selenium:4444/wd/hub'

5. Run the following command to run the test suite: vendor/bin/behat --config <rogo_root_directory>/testing/behat/config/behat.yml

Ideas for the future

We can probably set things up so that our tests will run automatically in the cloud on something like: https://travis-ci.com/