Varbase Behat is a standalone testing framework, with a set of Gherkin Features and custom Varbase Context with custom step definitions, and assets, which help with the automatic testing for Varbase websites https://www.vardot.com
Homepage Repository Packagist Gherkin
# Varbase Behat # Varbase Behat is a set of Gherkin Features and custom Varbase Context with Custom step definitions, and assets, which help with the automatic testing for varbase websites. This page can help you to have all steps, which you need to run the Behat Gherkin Features to test a varbase website in your localhost machine. Predefined request, you will need to have a running Varbase website: - Apache/http/https server. - PHP server, and have the mod_rewrite enabled. - MySQL server. - Configure your PHP/MySQL to work well with Varbase, Have a look at https://bitbucket.org/snippets/Vardot/8rGL/dev-tools-installs snippets. - Download Varbase from https://www.drupal.org/project/varbase Drupal website. - Install Varbase by following the Installing Varbase 7.x-3.x https://www.drupal.org/node/2570843 documentation page. - Download Varbase Behat: https://github.com/Vardot/varbase-behat/releases After that you can go through the following steps. -------------------------------------------------------------------------------- 1. If you have a Varbase testing site at this location /var/www/html/[PROJECT_NAME]/docroot -------------------------------------------------------------------------------- 2. Download the latest Behat package from https://github.com/Vardot/varbase-behat repository, and place it in the folder as below. /var/www/html/[PROJECT_NAME]/behat -------------------------------------------------------------------------------- 3. Edit the file behat.varbase.yml and change: base_url: 'http://[PROJECT_NAME].local' -------------------------------------------------------------------------------- 5. Go to /var/www/html/[PROJECT_NAME]/behat/ Then run the following commands to install all required packages, Libraries from vendors. $ curl -sS https://getcomposer.org/installer | php $ php composer.phar install -------------------------------------------------------------------------------- 6. Open a new terminal window then start selenium2 at the port 4445. You can change the port number by changing the parameter. "wd_host: 127.0.0.1:4445/wd/hub" in the behat.varbase.yml file. $ cd /var/www/html/[PROJECT_NAME]/behat/selenium $ java -jar selenium-server-standalone.jar -port 4445 -------------------------------------------------------------------------------- 7. Run the behat command at /var/www/html/[PROJECT_NAME]/behat/ $ bin/behat features/example.feature -------------------------------------------------------------------------------- 8. Run this command. $ bin/behat features/google/google-search.feature -------------------------------------------------------------------------------- 9. Run this command with the .feature file to run the Gherkin Script in it to the installed site. $ bin/behat features/varbase/your-gherkin-feature.feature $ bin/behat features/project-name/your-gherkin-feature.feature -------------------------------------------------------------------------------- 10. Run this command to print all available step definitions $ bin/behat -di - use -dl to just list definition expressions. - use -di to show definitions with extended info. - use -d 'needle' to find specific definitions. -------------------------------------------------------------------------------- 11. All Varbase custom step definitions are tagged with #varbase tag. Example : after a run for bin/behat -di command. ================================================================================ default | Then /^I should see image with the "([^"]*)" title text$/ | #varbase : To Find an image with the title text attribute. | Example 1: Then I should see image with the "Flag Earth" title text | at `VarbaseContext::iShouldSeeImageWithTheTitleText()` default | Then /^I should see image with the "([^"]*)" alt text$/ | #varbase : To Find an image with the alt text attribute. | Example 1: Then I should see image with the "Flag Earth" alt text | at `VarbaseContext::iShouldSeeImageWithTheAltText()` ================================================================================ -------------------------------------------------------------------------------- Example : ================================================================================ $ bin/behat features/example.feature Feature: Example Scenario: Go to about page with no visual view. # features/example.feature:3 Given I go to "https://www.vardot.com" website # VarbaseContext::iGoToWebsite() When I click "About" # Drupal\DrupalExtension\Context\MinkContext::assertClick() Then I should see "meet the team" # Drupal\DrupalExtension\Context\MinkContext::assertPageContainsText() @mink:selenium2 Scenario: Go to about page using mink selenium2 # features/example.feature:9 Given I go to "https://www.vardot.com" website # VarbaseContext::iGoToWebsite() When I click "About" # Drupal\DrupalExtension\Context\MinkContext::assertClick() Then I should see "meet the team" # Drupal\DrupalExtension\Context\MinkContext::assertPageContainsText() @javascript Scenario: To search in Google about Varbase. # features/example.feature:15 Given I go to "https://www.vardot.com" website # VarbaseContext::iGoToWebsite() When I click "About" # Drupal\DrupalExtension\Context\MinkContext::assertClick() Then I should see "meet the team" # Drupal\DrupalExtension\Context\MinkContext::assertPageContainsText() 3 scenarios (3 passed) 9 steps (9 passed) 0m51.12s (47.83Mb) ================================================================================ 12. To see the report in HTML. Go and open this file in a browser. /var/www/html/[PROJECT_NAME]/varbase/behat/reports/index.html You will see the latest report for latest run. if you want to custom a report you can add --format pretty --out std --format html --out reports/report-$( date '+%Y-%m-%d_%H-%M-%S' ) to format and select your output. Example: $ bin/behat features/example.feature --format pretty --out std --format html --out reports/report-$( date '+%Y-%m-%d_%H-%M-%S' ) 13. If you want to run all Gherkin Features over a new Varbase site. You will need to create the list of Testing users, and Add French, and Arabic languages to the site. # -------------------------------------------------------------------------- # Create default testing users. # -------------------------------------------------------------------------- # You can do that manually by reading and following steps in the # features/tools/users/create-default-testing-users.feature # Or you can run it by the following command. $ bin/behat features/tools/users/create-default-testing-users.feature # -------------------------------------------------------------------------- # Add French language if we do not have it to languages in the system. # Add Arabic language if we do not have it to languages in the system. # -------------------------------------------------------------------------- # You can do that manually by reading and following steps in the # features/tools/languages/add-french.feature # features/tools/languages/add-arabic.feature # Or you can run it by the following command. $ bin/behat features/tools/languages/add-french.feature $ bin/behat features/tools/languages/add-arabic.feature # -------------------------------------------------------------------------- # After that you can run the following command: # -------------------------------------------------------------------------- $ bin/behat features/varbase/ --format pretty --out std --format html --out reports/report-$( date '+%Y-%m-%d_%H-%M-%S' ) then after that you can see the report in the /var/www/html/[PROJECT_NAME]/varbase/behat/reports 14. To test installation features you will need to use the varbase Install config file, as you can see in the following command. $ bin/behat --config=behat.varbase-install-config.yml features/install/installation_varbase_default-installation-to-initiate-a-site-for-a-client.feature