# Cucumber Boilerplate for Functional API Testing

Occasionally, it is necessary to supplement Flask's functional service tests with functional tests against the microservice's QA environment. Possible situations include:

* Legacy microservices without unit testing frameworks
* Microservices that interact with critical third-party services
* Microservices without testable frontends

Because of its readability, Cucumber is the preferred framework for this use.

## Installation in Micrservice Repo

1. Copy this boilerplate into the new repo and rename it `cucumber`
2. `grep` for `servicename`, and replace all uses with the name of the service
3. Add a shell script to the pull-request job in Jenkins:

   ```text
   cd cucumber
   bundle install
   rake ci:pr
   ```

4. Clone the `ows-features-functional-cucumber-tests` and change it as necessary

## Readme in new repo \(delete everything above this\)

### Setup

#### Ruby

1. Fork and clone this repo
2. [Install RVM](https://rvm.io/rvm/install) \(don't use brew, and don't use a ruby installer\)
3. Use RVM to install and select Ruby 2.2.0: `rvm install ruby-2.2.0`
4. Install the bundler gem: `gem install bundler`

#### Native Dependencies and Gems

1. Install gems using bundler: `bundle install`

#### Configuration

1. Copy `.env.shadow` to `.env`, and populate it with the necessary values

### Execution

Run `rake cucumber:all` to quietly run the entire suite.

Run `cucumber features/example.feature` to specifically run the feature.

Run `cucumber features/example.feature:8` to specifically run the scenario on line 8.

### Contributing

Run `rake cucumber:pr` to run PR tests against the current branch. If Rubocop finds a large number of errors, then you can automate some of the corrections with `rubocop -a`.

### Conventions

* Tag incomplete scenarios as `@wip`.
* Pass objects between step definitions using instance variables.
* Write features in [declarative](http://itsadeliverything.com/declarative-vs-imperative-gherkin-scenarios-for-cucumber)

  style

* Write features in a product-friendly way. See the cucumber suite in

  `ows-features` for examples.

