This is a sample Rest API test solution for sample endpoints. Tests are written using a combination of CucumberBDD, RestAssured, Junit & Maven.
- The test design is based on the concept of AAA design pattern (Arrange Act Assert).
- Tests are written in BDD Gherkin format in Cucumber feature files and it is represented as a living documentation in the test report.
- API calls & validations are made using RestAssured.
- This solution maps the Gherkin sentences to Java methods with the so-called Step Definition files.
- Environment variables are included in JSON files. In real time projects each environment can be configured with its baseurl to run the tests based on different environments.
- Java 8
- Maven
- Cucumber
- RestAssured
- Java IDE: intellij or eclipse.
├───config
├───resources
├───src
│ ├───main
│ │ └───java
│ │ ├───feature
│ │ ├───stepDefination
│ │ └───utility
│ └───test
│ └───java
│ └───testRunner
└───target
└───cucumber
└─── index.html
- src/main/java/feature - Cucumber features files describes test scenarios
- src/main/java/stepDefination - Cucumber step defination classes
- src/main/java/utility - Utility classes
- src/test/java/testRunner - Cucumber test runner junit class
- target/cucumber - Reports
- Clone the project.
- Make sure project name is same as repository name.
- Add Maven support to IDE.
- Maven will automatically downloads all the required dependency jars into the local repository.
- Install cucumber plugin to highlight the Gherkins syntax.
- cd $project_directory
- Open command prompt/terminal
- Clean project
mvn clean
- Run tests
mvn test
- Results can be viewed on console.
- HTML reports are recorded at RestApiTestingFramework/target/cucumber/index.html
- Reports can be extended using any third party tool.
satellites/[id]/positions
- Return the satellite information as default unit.
- Return the satellite data when the requested unit is kilometers.
- Return the satellite data when the requested unit is miles.
- Return the satellite data for multiple timestamps.
- Return HTTP error 400 if timestamp is not found.
- Return HTTP error 404 if id is not found.
- Return the satellite information as default unit when invalid unit is provided.
- JSON response schema validation.
- Return the satellite data for more than ten timestamps.
satellites/[id]/tles
- Return the TLE data in default format
- Return the TLE data in JSON format when JSON format is requested
- Return the TLE data in text format when text format is requested
- Return the TLE data in default format when format provided is invalid
- Return HTTP error 404 if id is not found.
- JSON response schema validation
- The existing test cases are located at src/main/java/feature
- The cucumber features goes in the features library and should have the ".feature" extension.
- You can start out by looking at them.
A site for tracking the location of and getting fly-over notifications for the International Space Station. https://api.wheretheiss.at/v1/satellites/
- Fork it!
- Create your feature branch: git checkout -b my-new-feature
- Commit your changes: git commit -am 'feature details'
- Push to the branch: git push origin my-new-feature
- Submit a pull request :D
- Rest Assured - for write RESTful APIs tests( http://rest-assured.io/)
- Cucumber for BDD design https://cucumber.io
- Cucumber-JUnit as Test Runner https://cucumber.io/docs/installation/java/
- Maven - https://maven.apache.org/