Skip to content

An API automation framework using Ruby Rspec. Rubocop integrated and client-api package is used as a core module.

License

Notifications You must be signed in to change notification settings

nareshnavinash/rest-api-automation-framework-ruby

Repository files navigation

Rest API automation framework in Ruby

This repo is to have test automation framework for REST API using Ruby. Rubocop and Travis CI integrated.

License: MIT Made with Ruby StackOverflow email me

Travis build status

Build Status

Prerequsite

  • Install RVM 2.7.0 in the machine
  • Clone the project to a directory.
  • Do gem install bundler in the folder path "../selenium-ruby-basic" in commandline
  • Give bundle install
  • Required package will be installed from Gemfile.

To run the tests

  • Now run the test by rspec
  • Allure report can be get by giving allure serve reports/allure
  • Logs will be available under reports/logs

Tagged run

  • To run the tests based on the tags rspec --tag sanity or rspec --tag regression
  • Its better to have two modes of run within the same tests suite in order to have quicker turn over once the build is deployed

Parallel run

  • To speed up the execution, run the tests in parallel way by trying parallel_rspec spec/
  • This will split the number of spec files which we have according to the number of cpu cores available in the machine

Folder Structure Definitions

Libraries

  • Library folder is to have all the common methods that will be used for this project.
  • In this sample framework I have config methods to parse and get the run configs.

Spec

Test-data

  • This folder has all the test data that will be used for this project.
  • Test files can be some upload files, csv, excel, conf, json or even yaml file.
  • Here I used YAML file to get the test input data in to the project.
  • As a best practice no hardcoding of values inside the project. All the variables has to be mentioned in the test-data folder and fetched inside the project

Reports

  • Reports folder has allure specific result files. These are some xml files which will be used while running allure serve reports/allure.
  • Results folder also has other form of reports like logs, response json from the api, and rspec_status
  • To support CI Integration JUNIT reporting is also integrated with the tests

Gemfile

  • All the dependencies should be mentioned here, so that all the gems can be installed in one shot.
  • Its better to specify the gem version for each gems that we use.

Spec Helper

  • Spec helper file will be created inside the Spec foler.
  • This file is used to declare all the required gems or folder paths that is needed to run the tests.
  • Inside each spec file we need to require only the spec helper file so that each spec is powered to access all the gems or files used within the project.

Files under root directory

.rubocop.yml & .rubocop_todo.yml

  • These files are used to hold the rubocop configurations specific to this project.
  • These files are auto generated after resolving the linter issues
  • Currently this project follows all the best practices mentioned by rubocop except Metrics/BlockLength <= 25

.travis.yml

  • Integrated with travis for CI to validate the linter errors using rubocop upon raising PR

Built With

Authors

License

This project is licensed under the MIT License - see the LICENSE file for details

Acknowledgments

  • To all the open source contributors whose code has been referred to create this framework

Happy Automating

About

An API automation framework using Ruby Rspec. Rubocop integrated and client-api package is used as a core module.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages