Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/wingify/rest-api-testing-framework
RestAssured based API testing framework
https://github.com/wingify/rest-api-testing-framework
automation-testing rest-api rest-api-framework restassured restassuredrestapi testing-framework
Last synced: 3 months ago
JSON representation
RestAssured based API testing framework
- Host: GitHub
- URL: https://github.com/wingify/rest-api-testing-framework
- Owner: wingify
- License: apache-2.0
- Created: 2022-07-29T06:57:24.000Z (over 2 years ago)
- Default Branch: master
- Last Pushed: 2022-08-12T05:49:31.000Z (over 2 years ago)
- Last Synced: 2024-04-16T18:57:12.280Z (10 months ago)
- Topics: automation-testing, rest-api, rest-api-framework, restassured, restassuredrestapi, testing-framework
- Language: Java
- Homepage:
- Size: 128 KB
- Stars: 12
- Watchers: 6
- Forks: 6
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Contributing: CONTRIBUTING.md
- License: LICENSE
- Code of conduct: CODE_OF_CONDUCT.md
Awesome Lists containing this project
README
REST API Testing Framework
[![Contributors][contributors-shield]][contributors-url]
## About The Project
* This project is a RestAssured based API testing framework.
* Underlying, it uses `RestAssured` - API testing library, `TestNG` - Third-party free library for Running tests,
and `Reporting Extent Reports` (library for interactive and detailed reports for tests).
* This Project provides solution to automate all your Rest API Test cases at a go.
* It is built in such a way that the core structure of this framework can be used to automate any of your REST APIs by adding your own code on top of it.
* This framework provides you the capability to log Curls for all your API requests which can help you debug incase of any issues.
* It also provides listeners and reports for better understanding of your test results.## Contents
* [Getting Started](#started)
* [Prerequisites](#pre)
* [Installation](#install)
* [Framework Details](#FrameworkDetails)
* [Built With](#specs)
* [Base Api](#baseapi)
* [Framework - What and Why?](#ww)
* [Packages](#package)
* [Main Package](#mainpackage)
* [Test Package](#test)
* [Reports](#reports)
* [Contributing](#Contributing)
* [Usage](#example)
* [Acknowledgments](#acknowledgments)Below are the things required to get started with the project.
This Project Requires Java and gradle to be installed on your system.
```sh
npm install java
npm i gradle --save-dev
```* Clone the repo on your local system.
```sh
git clone https://github.com/wingify/rest-api-testing-framework.git
```* Resolve all gradle dependencies.
* Use gradle test command to run your test files.## Framework Details
### Built With
- Java
- Gradle
- TestNG
- RestAssured (Java Library)We have used RestAssured RequestSpecBuilder as a basis for our API test framework. We have created a BaseApi class in which we have written wrapper methods over RestAssured.
### Framework - What and Why?
This framework is built using RestAssured library, and it is made in such a way that it can be reused by adding the code on top of it to automate any API. It has been made generic so that it can be used to automate any REST API.`src/main/java/` is the core package of framework. It contains different sub packages for various API testing functionalities. All the sub Packages will be discussed in the following sections.
* apirequestbuilder -
This package contains classes for creating API request.* basepackage -
It has 2 classes BaseApi and BaseTest. BaseApi class contains all the wrapper methods over RestAssured and BaseTest class contains the pre-requisite and post requisites for our test classes.* constants -
Inside this package we have classes which contains enum and constants.* listeners -
This package contains testNG listeners and it's implementations.* reports -
This contains implementation of testNG extent report.* requestpojo -
This package holds multiple pojo class which is used to create API request.* utils -
Inside this package we have multiple classes which contains utils functions related to test classes.`src/test/java/` is the main test package which contains all the TestClasses, TestData and TestSchema
* It contains all the test classes which uses testNG as test framework.
* TestData contains all the data in json format required while writing testcases for different functionalities.
* TestSchema contains all the schema files used for asserting response schema.`src/main/java/reports` is the report package which uses TestNG extent reports generating an interactive and detailed HTML reports for our API test cases.
```java
@Test
public static void login() {
String username = System.getProperty("username");
String password = System.getProperty("password");LoginBuilder login = new LoginBuilder();
Login loginJson = login.createLoginBody(username, password);
BaseApi api = new BaseApi();
api.setRequestParams(
loginJson,
BaseApi.MethodType.POST,
LocalConfigs.baseURI,
BasePath.LOGIN_PATH
);
Response response = api.execute();
TestUtilFunctions.validateStatusCode(response, 200);if (response != null) {
cookies = response.getCookies();
accountId = (int) TestUtilFunctions.getJsonValue(response, "accountId");
userId = (int) TestUtilFunctions.getJsonValue(response,"id");
userName = (String) TestUtilFunctions.getJsonValue(response,"name");
}
}
``````java
public Login createLoginBody(String username ,String password) {
Login loginRequest = (Login) TestUtilFunctions.mapJson(
"login.json",
new Login());loginRequest.setUsername(username);
loginRequest.setPassword(password);
return loginRequest;
}
```Contributions are what make the open source community such an amazing place to learn, inspire, and create. Any contributions you make are **greatly appreciated**.
Please go through our [contributing guidelines](https://github.com/wingify/rest-api-testing-framework/blob/master/CONTRIBUTING.md)
If you have a suggestion that would make this better, please fork the repo and create a pull request. You can also simply open an issue with the tag "enhancement".
Don't forget to give the project a star! Thanks again!1. Fork the Project
2. Create your Feature Branch (`git checkout -b feature/AmazingFeature`)
3. Commit your Changes (`git commit -m 'Add some AmazingFeature'`)
4. Push to the Branch (`git push origin feature/AmazingFeature`)
5. Open a Pull Request.## Contributors
- [Nakul Thaper](https://github.com/NAKULT)
- [Abhishek Joshi](https://github.com/Abhi591)## Code of Conduct
[Code of Conduct](https://github.com/wingify/rest-api-testing-framework/blob/master/CODE_OF_CONDUCT.md)
* [RestAssured Official Docs](https://rest-assured.io/)
* [TestNG Docs](https://testng.org/doc/)## License
[Apache License, Version 2.0](https://github.com/wingify/rest-api-testing-framework/blob/master/LICENSE)
Copyright 2022 Wingify Software Pvt. Ltd.
[contributors-shield]: https://img.shields.io/github/contributors/wingify/rest-api-testing-framework.svg?style=for-the-badge
[contributors-url]: https://github.com/wingify/rest-api-testing-framework/contributors