This framework is developed to test GitHub Teams API and Front End Testing as well.
- Gradle: v5.6.2
- TestNg: v7.1.0
- RestAssured: v4.3.0
- Extent Reports: v2.41.2
- JSON Simple: v1.1.1
- Log4j: v1.2.17
- Selenium Java: v3.141.59
- Gradle as build tool (A basic building block for CI/CD)
- TestNg for developing exhaustive tests
- RestAssured as the interface to automate Rest endpoints and related tests
- Extent Reports for HTML reporting
- JSON Simple to read and write JSON Object during REST call
- Log4j for textual logging
- Selenium Java to automate and interact with Front end based on JSONWireProtocall
The code base of above project is divided into two folders as per gradle division, src/main/ & src/test/. Let's understand the working of each class written within the folder:
It contains package within java folder: com.project.freecharge.utilities. There are two classes available within this package: Configuration.java and RestUtility.java. There is a resource folder within src/main where config.properties are kept.
This class is used to read value of all the properties written inside config.properties. It uses encapsulation and gives getters to read the properties values. These proeprties values are used throughout the project wherever required.
This class contains all the static methods which is used to perform REST calls, like GET, POST, PUT, PATCH, and DELTE. Apart from these operations, there are methods to perform other operations like getting response, status code, setting and resetting BASE URL, etc.
This file contains all the properties like access token, media types, etc which are used at project levels. This file is accessed by Configuration.java class.
It also contains package within java folder: com.project.freecharge. This package have two sub-packages which are- controller & test. Controller sub-package contains APITestBed.java, BaseTest.java & MyListeners.java classes, whereas, test sub-package contains all the test cases built with TestNG. So it mainly contains TestNg classes like BewkoofTest.java & GitHubTeamApiTesting.java. Further, resources folder contains four sub-folders which are-
- Container
- JsonBody
- PostJsons
- Suite
Let's understand each classes and folders.
This class contains all the common methods which are used by all the test cases. It contains methods to set up browser for front end testing, report generation and closing, tear down methods, etc.
This class contains @BeforeSuite & @AfterSuite annotations, which mainly sets & resets the BASE URI. It extents BaseTest.java class to re-use the test level common methods.
This class extends ITestListener interface which is used for auto logging and reporting the testing events like failure, success, test startups, test end process, etc.
This is TestNg class which contains all the test for GitHubTeams API testing. The tests are written within @Test annotation. Those tests are grouped by Positive Test and Negative Test and their priority of execution are set.
This is another TestNg class which contains test for front end testing of Bewkoof.com. The development of this test is currently in progress.
This folder contains all the third party plugins like chromedriver.exe.
This folder contains Json files which are mainly gathered by using GET call of REST API. It contains only those json body whose values are set as parameter for another methods at runtime like getting project id.
This folder contains all the JSON files which are used to perform POST call of REST API, like editing a team, creating a new team, etc.
This folder contains two testng.xml files. First, apitsuite.xml contains test class for GitHub Teams API testing. Second, frontendsuite.xml contains test class for front end testing. The configuration of these two xmls are done inside build.gradle file as test task which uses useTestNg() method.
This file is stored inside the root directory of the project. It stores all the logs generated during test exeuction and it is directly configured with log4j.xml file.
This folder contains all the HTML reports generated by Extent Report and it is stored in root directly of the project.
Go to src/test/resources/Suite/apisuite.xml, Right click and Run. So, API tests are executed either from apisuite.xml file or directly running that Testng class file which is stored inside test sub-package of src/test/java folder.
Go to src/test/resources/Suite/frontendsuite.xml, Right click and Run. So, Front end tests are executed either from frontendsuite.xml file or directly running that Testng class file which is stored inside test sub-package of src/test/java folder.
- Go to build.gradle file and directly run runApiTest() task to execute API test suite and run runFrontEndTest() task to execute frontend test suite.
- Use terminal and run command gradle runApiTest for executing API test suite and gradle runFrontEndTest for executing front end test suite.