-
-
Notifications
You must be signed in to change notification settings - Fork 9
Behavior Testing
To help ensure that the core services of Workshop.codes continue to behave as expected for the end-user, we employ behavior testing via Cucumber utilizing Capybara to simulate user input. The default RackTest driver is used for non-JavaScript features due to its speed, with Selenium driving Firefox for JavaScript-reliant features.
In the current configuration, a Firefox installation supporting the most recent version of Geckodriver is required. On Windows and Mac, the latest stable release of the standard Firefox browser should suffice.
However, on Debian-based Linux distros, it should be noted that Firefox may, by default, be a Snap package. A Snap-packaged Firefox will not work with the current Geckodriver setup, as Snap Firefox lacks the ability to read the /tmp
directory where Geckodriver places the configuration files to launch Firefox. Please search for and follow instructions on how to install a non-Snap-packaged version of Firefox for your system, or set the environment variable TMPDIR
(e.g. TMPDIR=$HOME/tmp rake cucumber
) to a directory that Snap packages are allowed to access when running the tests.
-
features/
- Root folder for all Cucumber feature tests-
*.feature
- Behavior outline files -
support/
- Scaffolding and other setup files -
step_definitions
- Domain-specific language definitions written in Capybara. See the Cucumber docs for more information on writing step definitions
-
If using Rake, run
rake cucumber
Otherwise, run
bundle exec cucumber
Cucumber will automatically find all .feature
files under the features/
directory and execute them.
To run a specific feature test, run
[SEE ABOVE] cucumber features/[name].feature
Certain flags may be specified to make debugging failures easier.
Flags are set by setting the environment variable to the desired value. For example,
SEED=1234 bundle exec cucumber
All flags are listed below.
Flag name | Description | Possible Values |
---|---|---|
SEED | Sets the Kernel.srand seed to the specified value before every scenario. Useful for debugging scenarios which depend on random values. |
[number] |
LAUNCHY | Saves and attempts to open a snapshot after every step. Will probably fail if RackTest is being used instead of Selenium. |
1 to enable, 0 to explicitly disable |
DEBUGGER | Opens a Pry session upon failure. |
1 to enable, 0 to explicitly disable |
STEP | Halts execution after every step until a character is input to STDIN. |
1 to enable, 0 to explicitly disable |
PHOTO_MODE | Saves a screenshot after every step. Will probably fail if RackTest is being used instead of Selenium. |
1 to enable, 0 to explicitly disable |