API testing for beginners Start Smart with API testing
by Seven Peaks on Dec 9, 2020 11:33:00 AM
Unleashing your QA
QA as a first class citizen allows the creation of better tests, better quality which will be more functional as well as resulting in a system that is maintainable and runs well. There are different QA types/interests such as UI/UX, technical, security, business, automation, DevOps. Let’s dive right into our API testing for beginners guide below.
Our process at Seven Peaks Software
API Testing and Benefits
API testing is a software testing type that validates Application Programming Interface (APIs) which will be done in the business layer from the 3 layers; Presentation Layer, Business Layer and Database Layer in any application.
The purpose of API testing is to check the functionality of the programming interfaces. Seemingly, API tests are different from GUI Tests, also it won’t concentrate on the look and feel of an application.
Faster Time Resolution: API Testing consumes less time than functional and validation testing which save 3 hours of time on average.
Effective and Testing Cost Reduction: API testing requires less code tham GUI testing giving better test results and cost coverage which the faster the test results means a reduction in cost coverage.
Postman/Newman for API testing for beginners
Get the most out of testing with Postman/Newman
Postman is useful if you don’t have basic knowledge of coding and want to try API Testing. It is a collaboration platform for API development used to create better APIs. It can also be integrated with CLI using Newman.
Newman is a command line Collection Runner for Postman. It allows you to run and test a Postman to automate our API tests. You can install it for free on any operating system such as Linux, Windows and MacOS.
- Easily create test suites
- Store information for running tests in different environments
- Store data for other tests usage
- Easily move tests and environments to code repositories
Integrated with build systems, such as Jenkins using the Newman command line tool
It is possible to schedule your regression tests daily/weekly/monthly when the backend deliver a update in Jenkins. It is possible to generate an HTML report and export it later. Test script will be stored in Bitbucket.
Run collections using Newman
- Have Node.JS installed in your operating system
- Install Newman from npm globally on your system, which allows you to run it from anywhere.
- $ npm install -g newman
As we have the aggregated report of the collection, it is still possible to generate html reports and export it later for collections in HTML format.
- Install HTML reporter use command npm install -g newman-reporter-html
- Command to generate reports after the reporter installed
- $ newman run
https://www.getpostman.com/collections /my_api_documentation -e –reporters=cli,html
What are Postman Monitors?
Postman monitors are collection monitors that are set up and executed as per configure frequency which is used to run collection at a particular frequency. The results are required to be monitored and failures will be notified through Email or Slack.
What’s the use of Workspaces in Postman?
Postman workspaces are collaboration areas or spaces for colleagues or team to work on the same collection or set of collections.
Requests which get executed through the Postman application, are available for reference in the history section. Therefore, if any request was not saved to a collection before it was executed, you can go to the history section to get the executed request and save it to the collection.
Fiddler for API testing for beginners
Fiddler is basically a data monitoring tool that allows you to easily see incoming and outgoing HTTPs traffic. Log and suspect all traffic between your computer and the internet and can also mock requests/responses. It is now available in all operating systems.
Quick setup flow
- Download the Fiddler installer from its website here
- Configure the Fiddler Server which will take not more than 30 minutes
- Lastly, Configure the Fiddler Client
Features & Benefits
- Easily observe traffic from any applications that uses proxy and decrypt HTTPs web sessions used to check the API, endpoints and error codes .
- Tamper client requests and server responses use to mock test data if there are any troubles.
- Can be used for Debugging web traffic which we can inspect the trafficking of what we are sending to the server or the encrypted that we are receiving.
- Can be used for security testing.
Is fiddler available to Mac OS?
Yes! in their latest version this year 2020, they now support Mac OS and aside from Mac OS Fiddler also supports Linux and Windows.
Can we see the traffic from Mobile only or PC only?
Both. As long as the device is connected to a proxy and has successfully set up the certificate, we will be able to see and play around the request and response from the (client web or mobile).
For API testing, which one do you prefer: Postman or Fiddler?
Fiddler is quite a good tool for testing, especially for API testing for beginners, since there are a lot of things we can do with it like seeing API and modifying request and response. But focusing on just API testing, Postman will still be the best tool to use. But if testing revolves around traffic checking, modifying traffic (ingoing and outgoing), Traffic checking from mobile devices, bandwidth throttling, etc. Fiddler is the right tool.