In the previous tutorial, we worked our hands-on Postman Monitors which was about automated testing and learning how to schedule Collection run when you are not present or working on your system. Postman Monitors helped us in running Postman collections/executing tests at different time zones and at a different time in the same time zone without our intervention. It also automatically notifies us at regular intervals or when something goes wrong with the tests. This made us familiar with the concept of automated testing in Postman. Along with the command-line interface, this post will also introduce a new tool called Newman. We will use Postman with Newman later into the course.
In this tutorial we will work brief you about:
- What is Command Line Interface?
- What is Continuous Integration?
- What is Newman in Postman?
What is Command Line Interface?
As the name suggests a command-line interface is a means of interacting with a computer program (or software) by typing line by line commands in your shell (command prompt or terminal). It is fairly common among the people related to computer science but it is also very well known among people who use a laptop or PC for their work.
Command-line Interface or CLI was the main (or primary) source of interaction with a computer when the computers were just born. It was common in 1970s and 1980s. A command line interface works through a shell which converts your textual commands into operating system commands or functions to work on it. Since now powerful GUIs are available, it is not so common as it used to be. According to Wikipedia Programs with Command Line interface are easier to automate via scripting. A shell of windows (command prompt) used for operating a program is shown below.
If you are really interested into knowing different softwares which uses CLI, history of CLI and everything else you can visit here.
What is Continuous Integration?
Many a times a developer works in a team/group and the team can be distributed in a room, in a same office or over the world. You might not have seen each other but you all work together on the same project developing different modules or modifying the same code base. Now let suppose, you add a new piece of code or edit a old piece of code. This change now needs to reflect to everyone so that they can be aware of the change you did in the program. A continuous integration means continuously integrating your changes and program to reflect in the online repository (or cloud).
This image shows three stages which is a graphical representation of what I stated above. Deploying is integrating to the main build and testing is the API testing on the new code while development is simply developing and making changes to the code. In a project, Back-end apis are very important for the system, as the whole frontend works on the same API Services. A lot of logic is written for the functionality of API Services. Developers continuously alter the code and this can affect the API working and test results. Therefore there is a continuous need of executing the tests so that we are assured about the perfect working of APIs. This is done by unit tests which verifies the code issues and Postman tests. Unit tests are written by developers while the Postman tests are written by test engineers. Postman tests verify the actual integration as a whole. As soon as a change is reflected in the code, it is integrated with the main build to perform the API tests on it by which we can be assured that the patch/code is working successfully.
If we talk about the continuous integration in technical terms, a continuous integration is a practice in software engineering where every change is reflected in the larger code base such as a repository so that if there is any defect or modification, it can be identified as soon as possible. Continuous integration is very useful in automated testing, since you continuously alter the code, and the latest code is continuously verified by automated tests.
What is Newman in Postman?
Newman is a CLI (Command-line interface) tool which allows you to run a Postman collection directly from the command line. According to the official website of Postman, they describe Newman as a command-line Collection Runner for Postman. This makes Postman with Newman a special mix. Newman allows you to run collections in the same way they are executed inside a Postman collection runner. As we discussed in the above section, continuous integration helps us to combine the different codes and execute tests continuously. This amalgam of tests and code is a success due to continuous integration, which in Postman is done by Newman.
Postman Newman is built to easily integrate it with your build systems and continuous integration server. By this feature, developers get a quick feedback on the performance of APIs after their code changes. As with the help of Newman, it gets integrated with CI and thereafter if any change is pushed, CI will run the postman collections with Newman.
Newman is built on node.js which you can learn here. As it is built on node.js, it uses the default package manager for node.js which is npm. We will get familiar with node.js and npm in the next tutorial and will also download it in our systems.
These things will be clear in your mind once we start working on Newman. I hope you have got familiar with it a little bit. In the next tutorial we will learn How to Install Newman on our systems.