<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Jagan Karan</title>
    <description>The latest articles on DEV Community by Jagan Karan (@jagankarunakaran).</description>
    <link>https://dev.to/jagankarunakaran</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F764984%2Ffd256f09-6d0f-4ce7-90d3-8baf7f65d65d.jpeg</url>
      <title>DEV Community: Jagan Karan</title>
      <link>https://dev.to/jagankarunakaran</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/jagankarunakaran"/>
    <language>en</language>
    <item>
      <title>Postman/Newman - Test my Application</title>
      <dc:creator>Jagan Karan</dc:creator>
      <pubDate>Mon, 06 Dec 2021 10:55:34 +0000</pubDate>
      <link>https://dev.to/jagankarunakaran/postmannewman-test-my-application-4il9</link>
      <guid>https://dev.to/jagankarunakaran/postmannewman-test-my-application-4il9</guid>
      <description>&lt;p&gt;Functional and Regression testing of the application by a developer, will always enhance the quality of the code and also ensuring that the existing features are not broken.&lt;/p&gt;

&lt;p&gt;As a developer working on the RESTFUL services, the application extensively used to test REST API endpoints is &lt;strong&gt;Postman&lt;/strong&gt;.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;&lt;strong&gt;Postman&lt;/strong&gt; is a standalone software testing API (Application Programming Interface) platform to build, test, design, modify, and document APIs.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;Well-documented Postman collection will always help any developer to use the application APIs in various environments on the go. Other than documenting the APIs in postman it can also be used extensively like designing the test cases and validating the feature or flow of the application on a single run.&lt;/p&gt;

&lt;h3&gt;
  
  
  Postman Collections:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;On the Postman application, click the &lt;code&gt;new&lt;/code&gt; option and select the &lt;code&gt;Collection&lt;/code&gt; option.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6pycqw5azbqb1van8hmv.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6pycqw5azbqb1van8hmv.png" alt="Create Collection"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Once the collection is created, we will be able to add various scripts, environment variables to be used to the collection.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Pre-Request Scripts:&lt;/strong&gt; This option allows you to run the script before making the request. For instance, you can set the environment variables before making the request.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;&lt;strong&gt;Variables:&lt;/strong&gt; This option allows the addition of the environmental values to be used in the collection.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh9n04fcx12n0f7c5ja3v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fh9n04fcx12n0f7c5ja3v.png" alt="Collection Options"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;New folder can be created inside the parent collection for each flow, which includes all the requests needed to complete the particular flow. For instance, Create student flow can have requests like &lt;code&gt;create student endpoint&lt;/code&gt; and &lt;code&gt;get student endpoint&lt;/code&gt;.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkgz6i6lhdqr5lcqmp05q.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkgz6i6lhdqr5lcqmp05q.png" alt="Individual use case"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Both the requests inside the collection will have the required test cases written inside the test tab.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdclnmg6oml8rt27j8ltr.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fdclnmg6oml8rt27j8ltr.png" alt="Test cases"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;This test should have all the test cases designed by the developer which is expected for an endpoint to be returned, which ensures the endpoints are working as expected.&lt;br&gt;
&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0iroklq9k68det90zfwb.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F0iroklq9k68det90zfwb.png" alt="Test results"&gt;&lt;/a&gt;&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  Newman tool:
&lt;/h3&gt;

&lt;p&gt;Newman is a command-line collection runner for Postman. It allows you to effortlessly run and test a Postman collection directly from the command line.&lt;/p&gt;

&lt;p&gt;Once the postman collection is created with all the flows needed for the application, a developer can leverage `Newman's tool to run the postman collection and validate the test cases.&lt;/p&gt;

&lt;p&gt;Newman provides out of box reporting formats which include `cli, json, HTML, JUnit.&lt;/p&gt;

&lt;p&gt;Newman can also be integrated into the CI/CD pipelines to automate the validation of the application. &lt;/p&gt;

&lt;h3&gt;
  
  
  Installing Newman:
&lt;/h3&gt;

&lt;p&gt;&lt;code&gt;nodeJs&lt;/code&gt; has to be installed in your system based on your distribution.&lt;/p&gt;

&lt;p&gt;Run the following command to install the npm package of newman globally.&lt;br&gt;
&lt;code&gt;npm install -g newman&lt;/code&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Reference Application:
&lt;/h3&gt;

&lt;p&gt;Source code for the sample spring application with CRUD operations and postman collection with the test cases can be found in the following link:&lt;/p&gt;

&lt;p&gt;&lt;a href="https://github.com/JaganKaran13/postman-runner-and-testing" rel="noopener noreferrer"&gt;Postman Runner and Testing Github&lt;/a&gt;&lt;/p&gt;

&lt;h3&gt;
  
  
  Run and Test the application:
&lt;/h3&gt;

&lt;ul&gt;
&lt;li&gt;Clone the above git repo and run the java application on your preferred IDE.&lt;/li&gt;
&lt;li&gt;Import the collection to the postman and run the collection using a runner.&lt;/li&gt;
&lt;li&gt;To run in CLI, use the following command inside the postman directory through the terminal.
&lt;code&gt;newman run file.json&lt;/code&gt;
&lt;/li&gt;
&lt;li&gt;To run the test and display/store the result, use the following command.
&lt;code&gt;newman run file.json -r cli&lt;/code&gt;
&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fqbgyb92wnomubyihzr25.png" alt="Cli Response"&gt;
&lt;/li&gt;
&lt;/ul&gt;

&lt;h3&gt;
  
  
  References:
&lt;/h3&gt;

&lt;p&gt;&lt;a href="https://www.npmjs.com/package/newman" rel="noopener noreferrer"&gt;Newman NPM&lt;/a&gt;&lt;br&gt;
&lt;a href="https://learning.postman.com/docs/running-collections/intro-to-collection-runs/" rel="noopener noreferrer"&gt;Postman Runner Collection&lt;/a&gt;&lt;br&gt;
&lt;a href="https://learning.postman.com/docs/running-collections/using-newman-cli/command-line-integration-with-newman/" rel="noopener noreferrer"&gt;Postman Newman integration&lt;/a&gt;&lt;/p&gt;

</description>
      <category>performance</category>
      <category>webdev</category>
      <category>showdev</category>
      <category>testing</category>
    </item>
  </channel>
</rss>
