API QA Framework Integration – DevOps Way
The idea is to get a project/product level API QA framework creation and to empower the implementation through DevOps way of doing.
- Jenkins latest version with pipeline plugin
- Get Jenkins up and running in local
- Assertible, set up steps as suggested in the referred blog, with this unit testing set up will be ready for the API https://devonblog.com/software-development/assertible/ In this case: The target URL in the set up for unit testing is: https://snatarajan-eval-test.apigee.net/enecopingproxy with basic auth as username – admin and password – admin
- Download and install Slack(Windows/Mac/Ubuntu)
Create an organisation in slack registered with an email account
- Apickli – A NodeJS based API Integration testing suite built on cucumber JS framework
- Check out Apickli from the GitHub repository : https://github.com/apickli/apickli or install NPM https://www.npmjs.com/package/apickli
- The structure in local should look like below :
- Configurations required for apickli to execute :Each integration test has to be configured as feature in apickli, in this case I created a new feature called ‘myapi-test.feature’, and it verifies a successful invocation of the API endpoint with suffix /enecopingproxy and validate the response code as ‘200’File content of ‘myapi-test.feature’Feature:
Httpbin.org exposes various resources for HTTP request testing
As Httpbin client I want to verify that all API resources are working as they shouldScenario: Setting headers in GET request
Given I set User-Agent header to apickli
When I GET /enecopingproxy?username=admin&password=admin
Then response code should be 200As per node js, the base configuration of any NPM package is package.json and for apickli the configurations as below
File content of ‘package.json’
Now that all the component level configurations are completed for the Devops integration of the QA framework.
- Jenkins configurations and job execution
- Unit Testing Job
This job is to perform unit testing of the API end point by invoking the Assertible unit test suiteIn here, I created a batch file called ‘openurl.bat’ to invoke the assertible unit testing URL.
Content : START iexplore.exe https://assertible.com/apis/f0835f22-d6fa-490e-8ba9-096862bb2275/run?api_token=sQgKXBOLBVtmUXwtIn the similar way you can invoke a CURL command if you using MAC or Linux OSIn the POST-BUILD actions, invoke the Integration Testing Job so the next course of integration testing methods will be executed.
- Integration Testing JobAll the set of configurations done for the apickli is ready to be invoked now.The npm run command has to be invoked as a Build – ’Execute windows batch command’
- Pipeline view creation
Execute the Unit testing job by clicking play button:
Review pipeline for the Job status:
Verify the jobs console:
- Unit Testing Job
Feel free to refer to the full-fledged demo starting from git integration through to deployment and Integration testing by accessing the link – https://www.youtube.com/watch?v=7akulsVIy3M&feature=youtu.be