Automated Automation of REST APIs Harshit Kohli Amit Chauhan
APIs vs WebServices F.R.I.E.N.D.S JOEY
APIs vs WebServices Web Services are a subset of the generic term API(Application Programming Interface) All Web Services are APIs but all APIs are not WebServices A Web Service is simply an API wrapped in HTTP APIs – Selenium, Rest Assured Web Services – Google Maps REST API, GitHub REST API
REST
Why REST APIs ? Easy to build Easy to use Fast
Swagger Interface to REST APIs allowing discovery of the capabilities offered Industry Standard for API documentation Offers an interactive console to “try” out the API Developer and Tester friendly
Testing REST APIs
Testing REST APIs (the automated way!)
Ingredient 1 – REST Assured Wrappers Break Rest Assured calls into parts :– Create Request Execute Validate Response API Object Model (AOM) on similar lines of Page Object Model (POM) Reusability of Code Better Maintenance
Ingredient 1 – REST Assured Wrappers https://github.com/kohli-harshit/automated-automation-demo/blob/master/src/test/java/TestPetStore.java
Ingredient 1 – REST Assured Wrappers https://github.com/kohli-harshit/automated-automation-demo/blob/master/src/main/java/api/user/login/GetUserLoginApi.java
Ingredient 2 – Swagger Parser Parse the Swagger documentation using its JSON
Ingredient 2 – Swagger Parser Read JSON using :- JsonPath (https://github.com/json-path/JsonPath) JsonSimple (https://github.com/fangyidong/json-simple)
Ingredient 3 – Auto Generation of Code JavaPoet (https://github.com/square/javapoet) JavaPoet is a Java library for generating .java source files. It offers models for classes & interfaces, fields, methods & constructors, parameters and annotations. Sample code:
Ingredient 3 – Auto Generation of Code Jsonschema2pojo (http://www.jsonschema2pojo.org/) Generates Plain Old Java Objects from JSON
Ingredient 4 – JavaFX GUI Used to create cross platform rich user interfaces Easy to create UI through Scene Builder CSS Support – CSS Styling can be applied to elements(just like Web!) Embraces MVC Design Pattern Fast!
Ingredient 4 – JavaFX GUI Steps to create a JavaFX Application in IntelliJ (https://www.jetbrains.com/idea/download):- Create a JavaFX Application in IntelliJ Update FXML using Scene Builder(http://gluonhq.com/products/scene-builder/) Add code to Controller class
Open Source version coming soon…
Questions ?