We have created API automation framework using which we can automate APIs provided in PETSHOP domain.
Here is the Document Link --> https://gorest.co.in/
-
Technology stack
- Maven : For Decency management
- Java : As Programming language
- RestAssured: Library for client-server communication. Can also be replaced easy with other library as well without affecting single test
- JUnit 5/jupiter
- Log4j : For logging purpose
- GSON : Gson for serializing/deserializing String to Class and vice-versa
- IDE: IntelIj or similar Java capable IDE would be good.
-
How to Use this framework:
- For any request/response, we have to create pojo classes in main's dto package. This will help to create request/response for particular API.
- Add API URL into URLManagement.java file
- Once you have created Pojo, please create below methods:
- Getter classes for all variables : To achieve Encapsulation and data hiding
- Builder methods : Builder patter will help to create object easily.
- Override below methods (On need basis):
- toString
- hashCode
- equals
- Once you are ready with pojo classes and other configuration:
- Create package for your API in src/test/java
- Add testcases as per your API.
- If its POST/PUT API then create FactoryMethod which will help to give sample payload.
- As per test you can modify such payload.
- Make sure to add proper loggs and method commenting for better understanding.
- If you are working on POST API, make sure you delete the data as well using DELETE API or directly from Database
- We have added below details in property file, so that we can run same test in different env without changing single line of a code.
- Host
- Maximum Response time, we want.
- authorizeToken
- Using this approach it will be very easy to marinate, if request parameters are changed, or even we have to do assertions of large dataset.
- We have tried to capture document at each method/class level, if you are not able to understand something, do let me know. Would be more than happy to assist.
-
Suite
- We have created test suits using 'Tags' in junit. Here we have created 'SmokeTestSuite' which will execute all the testcases having 'smoke' as tags.
-
Open Points
-
Somehow i was not able to figure out request for Comment section, hence kept it with skeleton only
-------------Feedback is always welcome-------------
-