Skip to content

mikejramsey56/cuke-test

Repository files navigation

##Cuke-test##

A LoopBack project which provides a local web end point for API testing using Ruby and cucumber.

The API test software can be found under the spec folder.

This project was developed on Centos7. I doubt very much that it will work in Microsoft Windows.

###Starting LoopBack###

LoopBack is a free part of StrongLoop. You can go to their website to learn more about LoopBack. LoopBack provides a local web server target. You can customize which HTTP requests LoopBack accepts and what responses to send back. This first version is using very simple requests/responses. It is anticipated that more complex scenarios will be created in the future.

  1. Open a bash terminal
  2. cd to your cuke-test folder. This is the project root folder.
  3. Type slc run and press enter
  4. The bash terminal is now your console.log
  5. Open a browser (I use Firefox) and enter URL http://0.0.0.0:3000/explorer
  6. Currently, Veggies is supported so select it
  7. Observe that various HTTP requests are supported. Use Try It buttons to see how requests and responses are formed.

###The cucumber tests###

The cucumber tests are located in the spec folder. Cucumber is designed to support Business Driven Development.

Cucumber is a ruby gem. You will need to install Ruby 2.2.0.

After dowloading cuke-test:

  1. Open a bash terminal
  2. Type gem list bundler
  3. If bundler is not found, type gem install bundler and press enter
  4. cd to the cuke-test project root folder
  5. cd spec
  6. Type bundle install and press enter
  7. This will install the gems needed by this project

Cucumber tests consist of:

  • Feature files, each describes the tests for a User Story.
  • A Feature contains one or more Scenarios
  • Each Scenario contains a list of Given, When and Then statements that describe from a business perspective the desired application behavior
  • Step definition files are Ruby files which contain the code implementations for the Given, When, and Then statements.
  • There are support files under the support folder

To lauch the cucumber tests

  1. Make sure that the LoopBack cuke-test application is running in a bash terminal window (see above)
  2. Open a second bash terminal
  3. cd cuke-test/spec
  4. Type cucumber and press enter

###HTTParty###

Httparty is a Ruby gem that allows you to create and send HTTP requests to a URL and receive responses. Rspec/expectations are used to make assertions about expected behavior.

No browser is utilized by these tests which makes their execution very swift. The tests target the local LoopBack URL. LoopBack can be made to mock any real API. And of course real API's can be the target of such tests. LoopBack is simply convenient.

About

A fully self contained ruby cucumber template project for testing web endpoint APIs

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published