-
Notifications
You must be signed in to change notification settings - Fork 0
Automated Testing
Nobody likes when software is broken, but it's a really unpleasant feeling to know you broke the software for others. As a first line of defense against broken software, ChurchCRM uses automated, browser based testing. We've developed a set of scripts that emulates a real user by clicking and typing in strategic locations within the application to ensure that all of the features work as intended.
We've automated testing of some of the critical functionality. This way, components are tested every time any code is changed.
There are many different automated testing strategies (unit testing, integration testing, etc). As ChurchCRM matures, so will our testing strategies; however, we're currently only using browser automation testing. This form of testing gives us the largest amount of code coverage for the smallest amount of testing code.
- Behat
Behat is a PHP framework for driving the various browser automation test drivers
- MinkExtension
MinkExtension provides additional capabilities to Behat
- Gherkin
Gherkin is the language used to write the browser automation tests. It is considered an External Domain Specific Language because it allows a QA developer to write a test for ChurchCRM without any PHP knowledge. The tests read as "plain English" Syntax Examples: https://gist.github.com/mnapoli/5848556
- SauceLabs
SauceLabs generously provides us with hosting of a Slenium Grid. Think: a server farm running a bunch of web browsers, clicking on things automagically.
- Selenium
Selenium is an open source project that allows QA developers to interact with browsers in a scripted, automated manner.
https://github.com/minkphp/MinkSelenium2Driver http://docs.behat.org/en/v2.5/guides/7.config.html https://michaelheap.com/behat-selenium2-webdriver-with-minkextension/ http://mink.behat.org/en/latest/drivers/selenium2.html
ChurchCRM uses Behat for page load testing Behavior Driven Development.
- While SSH'd into the vagrant development box, run the following commands:
cd /vagrant
npm test
- You should see the result of all individual tests.
Behat page tests use the gherkin syntax.
Behat uses tests written with this syntax to execute requests and validate responses against the defined pages.
All tests should follow this outline:
Feature: Calendar
In order to see calendar events
As a User
I am able to visit the calendar
Scenario: Open the calendar
Given I am authenticated as "admin" using "changeme"
And I am on "/calendar.php"
Then I should see "Church Calendar"
- Supplying input values, Navigating Pages: FamilyAdd.Feature
- Defining new gherkin verbs:
iAmAuthenticatedAs
: FeatureContext.php
Unit testing is not yet fully implemented.
-
On the bottom of the PR for which you want to view test results, click "Details" next to the appropriate test:
Access to the TravisCI tests for a specific commit is also possible by clicking the "Test Status Indicator" to the right of the commit:
-
Click on "Details"
-
Click one of the builds
-
Review the logs. The bottom of the log will contain Selenium test results:
-
From the TravisCI job page, click the "Restart Job" button for either all jobs, or a specific job:
- https://saucelabs.com/blog/adding-sauce-to-behat
- https://github.com/jaffamonkey/behat-3-kickstart
- https://docs.travis-ci.com/user/sauce-connect/
- https://www.linkedin.com/pulse/github-travis-ci-saucelabs-connecting-dots-natarajan-cms-cste-
- http://mink.behat.org/en/latest/guides/session.html
- https://gist.github.com/mnapoli/5848556
- http://www.tentacode.net/10-tips-with-behat-and-mink
- http://elnur.pro/use-the-domain-language-in-bdd-features/