POSTMAN requests and tests can be run in different ways. One of the ways is to run tests directly from the POSTMAN interface by writing scripts and there are other ways is to run the test using frameworks such as Newman and Jenkins.
In our previous article, we have seen how to run a collection from the command line using Newman and npm. Now let us see how to run the POSTMAN test using Jenkins.
Jenkins is a continuous integration tool written in Java and is an open-source tool. It can be used as a continuous integration server to performs a chain of different actions leading to an integration process.
This is a server-based application and requires a web server like Apache or Tomcat. The popularity of Jenkins lies in the fact that all the faults and errors can be detected at the early stages of software development. Jenkins achieves this by letting you continuously test your build project and find the error in the early stages of development.
Some of the reasons are below:
There are different advantages of using Jenkins, some are stated below:
There are disadvantages of using Jenkins, though it is powerful and of the most widely tool. Some of them are:
When a particular task is completed by a developer working in the software development phase, then he/she can commit the code when completed. Now, when there are many developers working on the same project, they may need to commit multiple times in a given time. And also the commit time for all the developers may be different.
Now, when someone completes his piece of work, then he makes a code commit. After the commit, the build starts, then the test is started and then the deployment starts. So basically we can see that it goes like this: code commit->build->test->deploy.
This process keeps on rotating for all the individual developers until the project is completed. This process is called continuous integration.
The continuous integration process includes hosting, monitoring, compiling, testing code, etc. And so tools necessary are:
Jenkins will allow you only to use some set of a limited set of features. If Jenkins has to be integrated with other tools then there are plugins that need to be installed. Suppose, if you want to integrate your Jenkins with GIT then the GIT plugins have to be installed.
To run a test from Jenkins, we see the two following things:
Before you start using Jenkins, the Jenkins software must be installed in your system.
Download Jenkins: Visit the official page of Jenkins: https://jenkins.io/download/
Now, click and download the
.war file. (for windows users).
Once the file gets downloaded, just create any folder on the desktop(optional) and move the
jenkins.war file into that folder.
I have named my folder jenkins (you may use any name.). Now open the command prompt and change the path to the same jenkins folder directory.
Now, type the following command:
java -jar jenkins.war.
Now, you should see that the jenkins set-up has started in the command prompt itself.
The above way may not work every time while installing Jenkins. The other way to install Jenkins is by directly using the Jenkins Installer where you will be asked whether you want to download and install necessary plugins at the same time as installing the software.
visit the link: https://jenkins.io/download/ and hit the download button as shown in the below interface.
The Jenkins file which you will download will be a
.rar file and you have to extract it.
Now, you will get the actual file, which you can start installing directly into your system.
Once you click Install, you will be asked to proceed to the installation by clicking Next.
After clicking the Next button, the installation process for Jenkins will start. Sometimes, it may ask for selecting additional plugins and sometimes it may install the required plugins by default.
Once Jenkins gets installed, you will see this interface after setting a username and a password. Jenkins will open in any of your chosen browsers and by default, it will load in the address:
localhost:8080. Just make sure that port 8080 is not used by any other applications or thread in your Operating system.
To run a test using Jenkins, the collection which you want to run has to be exported into a local directory of the system. Let us choose a collection and export it.
Go to POSTMAN and select the collection you want to export. Click into the three dots(...) sign beside the collection name and you will find an option to export the collection.
Once you select the export option, you will get some options on which files you want to export. There will a POSTMAN recommended one. You should choose that.
After selecting the radio button Collection v2.1 (which is the recommended one), click the Export button.
You may choose any directory, I have chosen the folder collection, which I have created inside the C drive. And save the file with any file name. But the extension should be
Once you save the file in the folder or directory, you are done with exporting. Now, go to your browser and load Jenkins. By default, your Jenkins should load into the PORT 8080, so type localhost:8080 into the URL bar and hit enter.
Now, once the page is loaded into your browser, you should see the page as below:
In the above image, you can see the welcome message from Jenkins, and below that there is an option for creating new jobs. Click to create new jobs to get started.
Now, enter any name of your choice. I shall name it as:
Then click on the Ok button which is on the same page to save the job.
Once you click the Ok button, the job will be instantly saved and you will see the job configuration page.
As you scroll down the page you will be navigated to the Build option.
Now, inside the while textarea, you can write the same Newman command, which you wrote in case of running the POSTMAN test in the command line, using Newman.
The steps to run the test would be:
.jsonfile exported. In my case, it is a collection folder inside the C drive. So, I shall use:
text.json. So, I shall use the Newman command:
newman run text.json.
cd/ cd collection newman run text.json
Now, click on Apply and then click Save. As you Apply and Save you will be automatically navigated into a page, where you will get the option to build your test.
Click on Build Now to build the test. It may take a few seconds to build the project and once complete you will be able to see it along with the date and time of creation.
Now, click on the built project (#2 in this case)to see different options such as console output, etc.
You may click the Console Output option to see the output.