Skip to content

Commit

Permalink
tests: add some notes for myself for the future
Browse files Browse the repository at this point in the history
  • Loading branch information
dustymabe committed Jul 20, 2016
1 parent 76336fa commit 7bd81c1
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 1 deletion.
21 changes: 21 additions & 0 deletions features/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@

We are using Cucumber for automated testing. Read more at the
following two links:

- [link1](https://en.wikipedia.org/wiki/Cucumber_(software))
- [link2](http://www.methodsandtools.com/tools/cucumber.php)

features/
This is the features directory. The features directory Contains
feature files, which all have a .feature extension. May contain
subdirectories to organize feature files.

features/step_definitions
This directory contains step definition files, which are Ruby code
and have a .rb extension.

features/support
This directory contains supporting Ruby code. Files in support
load before those in step_definitions, which makes it useful for
such things as environment configuration (commonly done in a file
called env.rb).
14 changes: 14 additions & 0 deletions features/sshfs_cwd_mount.feature
Original file line number Diff line number Diff line change
@@ -1,3 +1,16 @@
# The language in this file is Gherkin. It is the language Cucumber
# uses to define test cases and is designed to be non-technical and
# human readable. All Gherkin files have a .feature extension
#
# See more here: https://en.wikipedia.org/wiki/Cucumber_(software)
#
# Additoinally in the setup/env.rb file we set up Aruba. Aruba is used
# to define most of the basic step definitions that we use as part of
# the Gherkin syntax in this file.
#
# For more information on the step definitions provided see:
# https://github.com/cucumber/aruba/tree/bb5d7ff71809b5461e29153ded793d2b9a3a0624/features/testing_frameworks/cucumber/steps
#
Feature: SSHFS mount of vagrant current working directory

Scenario Outline: SSHFS mounting of vagrant cwd
Expand All @@ -23,6 +36,7 @@ Feature: SSHFS mount of vagrant current working directory
Then stdout from "bundle exec vagrant up" should contain "Installing SSHFS client..."
And stdout from "bundle exec vagrant up" should contain "Mounting SSHFS shared folder..."
And stdout from "bundle exec vagrant up" should contain "Folder Successfully Mounted!"
# The code for the following test is in ./step_definitions/sshfs_cwd_mount_steps.rb
And vagrant current working directory should be mounted

Examples:
Expand Down
8 changes: 8 additions & 0 deletions features/step_definitions/sshfs_cwd_mount_steps.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
# This is a cucumber step definition. Cucumber scenarios become automated
# tests with the addition of what are called step definitions. A step
# definition is a block of code associated with one or more steps by a
# regular expression (or, in simple cases, a string).
#
# This is the step definition for the `And vagrant current working
# directory should be mounted` step from sshfs_cwd_mount.feature
#
And(/^vagrant current working directory should be mounted$/) do
run("vagrant ssh -c 'ls /testdir/Vagrantfile'")
expect(last_command_started).to have_exit_status(0)
Expand Down
15 changes: 14 additions & 1 deletion features/support/env.rb
Original file line number Diff line number Diff line change
@@ -1,12 +1,25 @@
# This is a support file for the cucumber tests. This file sets up the
# environment for the tests to run. At this point mainly that means
# configuring Aruba. Aruba is used to define most of the basic step
# definitions that we use as part of the Gherkin syntax in our .feature files.
#
# For more information on the step definitions provided see:
# https://github.com/cucumber/aruba/tree/bb5d7ff71809b5461e29153ded793d2b9a3a0624/features/testing_frameworks/cucumber/steps
require 'aruba/cucumber'
require 'komenda'
require 'komenda' # use komenda for easily executing a command

# Configure aruba. The options can be inferred from here:
# https://github.com/cucumber/aruba/tree/bb5d7ff71809b5461e29153ded793d2b9a3a0624/features/configuration
Aruba.configure do |config|
# Wait up to 300 seconds for the test to run
config.exit_timeout = 300
# Output stdout and stderr on test failure
config.activate_announcer_on_command_failure = [:stdout, :stderr]
# The directory where the tests are to be run
config.working_directory = 'build/aruba'
end

# After running tests, clean up
After do |_scenario|
if File.exist?(File.join(aruba.config.working_directory, 'Vagrantfile'))
Komenda.run('bundle exec vagrant destroy -f', cwd: aruba.config.working_directory, fail_on_fail: true)
Expand Down

0 comments on commit 7bd81c1

Please sign in to comment.