<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0" xmlns:cc="http://cyber.law.harvard.edu/rss/creativeCommonsRssModule.html">
    <channel>
        <title><![CDATA[Stories by Rohithawuppugundur on Medium]]></title>
        <description><![CDATA[Stories by Rohithawuppugundur on Medium]]></description>
        <link>https://medium.com/@rohithawuppugundur?source=rss-b4bf214046e8------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/0*fIn0E5gJGm6Ddb3Z</url>
            <title>Stories by Rohithawuppugundur on Medium</title>
            <link>https://medium.com/@rohithawuppugundur?source=rss-b4bf214046e8------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 23:37:42 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@rohithawuppugundur/feed" rel="self" type="application/rss+xml"/>
        <webMaster><![CDATA[yourfriends@medium.com]]></webMaster>
        <atom:link href="http://medium.superfeedr.com/" rel="hub"/>
        <item>
            <title><![CDATA[Simplifying and Automating Tasks in API Testing using Postman]]></title>
            <link>https://medium.com/@rohithawuppugundur/simplifying-and-automating-tasks-in-api-testing-using-postman-daaeee61eb6e?source=rss-b4bf214046e8------2</link>
            <guid isPermaLink="false">https://medium.com/p/daaeee61eb6e</guid>
            <dc:creator><![CDATA[Rohithawuppugundur]]></dc:creator>
            <pubDate>Thu, 21 Sep 2023 04:51:56 GMT</pubDate>
            <atom:updated>2023-09-21T04:51:56.884Z</atom:updated>
            <content:encoded><![CDATA[<p>Here are few tips which will be useful while performing API Testing using postman tool.</p><p><strong>#1. Write Tests :</strong> Writing test is postman is easy and uses Java script syntax. Without good test ,we will not have full confidence on API behaviour &amp; consistency.This will save time when code grows and changes over time.Testing simple things like HTTP status Code , response time , headers can be done with single line code .We can even write more advanced logic to validate responses, Check business rules ,Assign data to variable and Dynamically control the workflow.</p><p><strong>#2. Documentation :</strong> We should never mix tests and documentation. API Documentation is for the <em>consumers</em> of an API, tests are for the <em>authors</em> of an API.These things must be included in API Documentation :</p><blockquote>Authentication instructions</blockquote><blockquote>Detailed information about every endpoint, operation, and resource</blockquote><blockquote>Examples of common requests and responses</blockquote><blockquote>Terms of Use</blockquote><p>#<strong>3.Organize tests into folders: </strong>As your API grows in complexity, it will become important to organize your tests so they make sense and can be found easily. Its best practise to use folders to group requests by resource, test suite, and workflows.</p><p>Resources</p><p>Create a top-level folder for each of your API’s resources like (users, orders, products, etc.).</p><p>Test Suites</p><p>The second-level folders would be test suites for each of those resources, such as “<em>Start a new order</em>“, “<em>Edit an existing order</em>“, “<em>Cancel an order</em>“, etc.</p><p>Workflows</p><p>The third-level folders are for more complicated tests that span multiple API calls. For example, your API might have a checkout flow that involves separate calls to create an order from a shopping cart, enter the shipping address, select the shipment method, and submit the payment information. In this case, you’d create a “workflow” folder named something like “<em>Checkout</em>” that contains the three requests.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*FZR89v70RHfyK7kg.png" /></figure><p><strong>#4. JSON Schema Validation : </strong>JSON Schema defines structure of request and response. Postman includes the tv4 library, which makes it easy to write tests to verify that your API responses comply with your JSON Schema definitions.We can even store the schema as a JSON string in a <a href="https://learning.postman.com/docs/sending-requests/variables/">Postman environment variable</a>. Then you can simply use the variable in your test script.</p><blockquote>Example :</blockquote><blockquote>// Load the JSON Schema</blockquote><blockquote>const customerSchema = JSON.parse(environment.customerSchema);</blockquote><blockquote>// Test whether the response matches the schema</blockquote><blockquote>var customer = JSON.parse(responseBody);</blockquote><blockquote>tests[“Customer is valid”] = tv4.validate(customer, customerSchema);</blockquote><p><strong>#5.Reuse Code: </strong>We can reuse JavaScript code the same way by using the eval() function.Most API’s have common rules which apply to all endpoints.For example certain Http Headers should always be set, or the response body should always be in a certain format, or the response time must always be within an acceptable limit. Rather than re-writing these tests for every request, you can write them once in the very first request of your collection and reuse them in every request after that.</p><blockquote>// Save common tests in a global variablepostman.setGlobalVariable(“commonTests”, () =&gt; {</blockquote><blockquote>// The Content-Type must be JSON</blockquote><blockquote>tests[“Content-Type header is set”] = postman.getResponseHeader(“Content-Type”) === “application/json”;</blockquote><blockquote>// The response time must be less than 500 milliseconds</blockquote><blockquote>tests[“Response time is acceptable”] = responseTime &lt; 500;</blockquote><blockquote>// The response body must include an “id” property</blockquote><blockquote>var data = JSON.parse(responseBody); tests[“Response has an ID”] = data.id !== undefined;});</blockquote><blockquote>//To run common test First</blockquote><blockquote>eval(globals.commonTests)();</blockquote><p><strong>#6. Automate your tests with Postman’s collection runner : O</strong>nce all the tests are written, you’ll want an easy way to run <em>all</em> of your requests quickly and see the results in a single view. That’s where Postman Collection runner comes into picture.</p><p><strong>#7.Automate your tests with Newman : </strong>The Postman collection runner is a great way to run all of your tests and see the results, but it still requires you to manually initiate the run. If you want to run your Postman tests as part of CI/CD , then you’ll need to use the Newman CLI.Newman can easily be integrated into <a href="https://learning.postman.com/docs/postman/collection-runs/integration-with-jenkins/">Jenkins</a>, or any other code deployment pipeline tool.</p><p>— -&gt; newman run postman collection.json</p><p><strong>#8. Automate your tests with Postman Monitors : </strong>You can use <a href="https://learning.postman.com/docs/postman/monitors/intro-monitors/">Postman Monitors</a> to automatically run your Postman tests at regular intervals, such as every night, or every 5 minutes. You’ll automatically be notified if any of your tests ever fail.</p><p>Postman Monitors shows your test results in the same familiar layout as the Postman collection runner, so it’s easy to compare the results to the Postman app.</p><p><strong>#9. Dynamically control test workflows : </strong>By default, the Postman collection runner, Newman, and Postman Monitors will run each request in your collection in order. But you can use the <a href="https://learning.postman.com/docs/postman/scripts/branching-and-looping/">postman.setNextRequest()</a> function to change the order. This allows you to conditionally skip certain requests, repeat requests, terminate the collection early, etc.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=daaeee61eb6e" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Annotation Helper Attributes in TestNG]]></title>
            <link>https://medium.com/@rohithawuppugundur/annotation-helper-attributes-in-testng-676f11e922b2?source=rss-b4bf214046e8------2</link>
            <guid isPermaLink="false">https://medium.com/p/676f11e922b2</guid>
            <dc:creator><![CDATA[Rohithawuppugundur]]></dc:creator>
            <pubDate>Mon, 25 Apr 2022 21:00:38 GMT</pubDate>
            <atom:updated>2024-02-22T05:46:27.013Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/300/0*qQjDqM4OcDbTCSG9.png" /></figure><h3>@Test: The @Test attribute is the most important and commonly used annotation of TestNG. It is used to mark a class or a method as part of the test.</h3><p>Now, let’s see some important attributes of<strong> @Test </strong>annotations</p><p><strong><em>description</em></strong></p><p>It is a string which is attached to the @Test annotation that describes the information about the test.</p><p><strong>Example:</strong></p><pre>@Test(description=&quot;Sample Description&quot;)<br>public void description(){<br>    System.out.println(&quot;Description of the method&quot;);<br>}<br>@Test(description=&quot;This is testcase2&quot;)  <br>public void testcase2()  <br>{  <br>System.out.println(&quot;Execution of methods&quot;);  <br>}</pre><blockquote><em>In the above code, we have added the description attribute in every test. The “</em><strong><em>description</em></strong><em>” attribute provides information about the test.</em></blockquote><p><strong><em>groups</em></strong></p><p>This attribute is specifically used to <strong>group</strong> the different test cases that belong to the same functionality.</p><p><strong>Example:</strong></p><pre>public class GroupsSample {<br>	@Test(groups=&quot;Smoke&quot;)<br>	public void Test(){<br>		System.out.println(&quot;Test group :Smoke&quot;);<br>	}	<br>	@Test(groups=&quot;Regression&quot;)<br>	public void Test1(){<br>		System.out.println(&quot;Test group :Regression&quot;);<br>	}<br>}</pre><blockquote><em>In the above code, we have declared two Test method with groups attribute .So when want to execute only “Smoke Testcases” we can only run that specific group and get results.</em></blockquote><p><strong><em>timeOut</em></strong></p><p>Here we specify the <strong>timeout</strong> value for the test method(in milliseconds) to execute. If the test takes more than the timeout value specified, the test terminates and is marked as a fail.</p><p><strong>Example:</strong></p><pre>@Test(timeOut=200)<br>public void Test(){<br>     Thread.sleep(500);  <br>    System.out.println(&quot;Executes Test&quot;);<br>}</pre><blockquote><em>In the above code, we have Thread.sleep(500) which means that the testcasemethod will be executed after 500 milliseconds, but we have provided timeOUT attribute with the value 200 means that the testcase will be failed after 200 milliseconds.</em></blockquote><p><strong>priority</strong></p><p>This attribute allows to decide the execution of the method, We can schedule the execution of the method when to run.Lower priority methods execute first and priority work in descending order.When no ‘<strong>priority</strong>’ attribute is specified then the TestNG will run the test cases in alphabetical order.</p><p><strong>Example:</strong></p><pre>public class Fruits  <br>{  <br>@Test  <br>public void mango()  <br>{  <br>System.out.println(&quot;I am Mango&quot;);  <br>}  <br>@Test(priority=2)  <br>public void apple()  <br>{  <br>System.out.println(&quot;I am Apple&quot;);  <br>}  <br>@Test(priority=1)  <br>public void watermelon()  <br>{  <br>System.out.println(&quot;I am Watermelon&quot;);  <br>}  <br>}</pre><blockquote><em>In the above code, the default priority of mango() test method is 0, so it will be executed first. The watermelon() test method will run after mango() method as the priority of watermelon() test method is 2. The apple() test method has the highest priority, so it will be executed last.</em></blockquote><p><strong>dependsOnMethods</strong></p><p>This attribute makes one test method dependent on another to execute.When the second test method wants to be dependent on the first test method, then this could be possible by the use of “<strong>dependOnMethods</strong>” attribute. If the first test method fails, then the dependent method on the first test method, i.e., the second test method will not run.</p><p><strong>Example:</strong></p><pre>public class Class1   <br>{  <br>@Test  <br>public void WebStudentLogin()  <br>{  <br>System.out.println(&quot;Student login through web&quot;);  <br>}  <br>@Test  <br>public void MobileStudentLogin()  <br>{  <br>System.out.println(&quot;Student login through mobile&quot;);  <br>}  <br>@Test(dependsOnMethods= {&quot;WebStudentLogin&quot;})  <br>public void APIStudentLogin()  <br>{  <br>System.out.println(&quot;Student login through API&quot;);  <br>}  <br>}</pre><blockquote><em>As we know Testing executes in alphabetical order, so now APIStudentLogin will execute first.But we want WebStudentLogin to execute first so this can be done only by using “</em><strong><em>dependsOnMethods” </em></strong><a href="http://attribute.so/"><em>attribute.So</em></a><em> now in above code WebStudentLogin executes first and then APIStudentLogin will be executed.</em></blockquote><p><strong>enabled</strong></p><p>This attribute is used if you know that one of the functionality or flow is not working or there is some bug that is already reported and we are aware of that then TestNG provides a feature to safely skip that test case and execute all other test <a href="http://cases.by/">cases.By</a> default, its value is true. If you want to skip some test method, then you need to explicitly specify ‘<strong>false</strong>’ value(Boolean Value).</p><p><strong>Example:</strong></p><pre>@Test (enabled=false)<br>public void ListCart()<br>{<br>System.out.println(&quot;List of all product displayed in cart&quot;);<br>}<br>@Test  <br>public void SearchProduct()  <br>{  <br>System.out.println(&quot;Search Product from List&quot;);  <br>}</pre><blockquote><em>In the above code, the value of the enabled attribute in ListCart() test method is false, so this method will not be invoked.</em></blockquote><p><strong>dataProvider</strong></p><p><em>DataProviders</em> pass different values to the TestNG Testcases in a single execution and in the form of TestNG Annotations.It is a part of the inbuilt TestNG data-driven testing for which TestNG is quite popular.<em>DataProviders</em> help in passing the parameters in different ways</p><p>For example:</p><pre>@DataProvider (name = &quot;name_of_dataprovider&quot;)<br>public Object[][] dpMethod() {<br>    return new Object [][] { values}<br>}</pre><p><strong>invocationCount</strong></p><p>This attribute is used to execute a method the number of times. It acts as a loop.</p><p>For example:</p><pre>@Test(invocationCount = 5) // This method will execute 5 times.</pre><h3><strong>TestNG Annotations</strong></h3><p>TestNG annotations are the code that is written inside your source test code logic to control the flow of the execution of tests. It is essential to annotate your methods in TestNG to run the tests.A TestNG annotation starts from the symbol “<em>@</em>” and whatever follows is the annotation name.</p><h3>Types Of TestNG Annotations</h3><p>In TestNG, there are ten types of annotations:</p><ul><li><em>@BeforeSuite</em> — <em>The </em><em>@BeforeSuite method in TestNG runs before the execution of all other test methods</em>.</li><li><em>@AfterSuite</em> — <em>The </em><em>@AfterSuite method in TestNG runs after the execution of all other test methods</em>.</li><li><em>@BeforeTest</em> — <em>The </em><em>@BeforeTest method in TestNG runs before the execution of all the test methods that are inside that folder</em>.</li><li><em>@AfterTest</em> — <em>The </em><em>@AfterTest method in TestNG executes after the execution of all the test methods that are inside that folder</em>.</li><li><em>@BeforeClass</em> — <em>The </em><em>@BeforeClass method in TestNG will run before the first method invokes of the current class</em>.</li><li><em>@AfterClass</em> — <em>The </em><em>@AfterClass method in TestNG will execute after all the test methods of the current class execute</em>.</li><li><em>@BeforeMethod</em> — <em>The </em><em>@BeforeMethod method in TestNG will execute before each test method</em>.</li><li><em>@AfterMethod</em> — <em>The </em><em>@AfterMethod method in TestNG will run after each test method is executed</em>.</li><li><em>@BeforeGroups</em> — <em>The </em><em>@BeforeGroups method in TestNG run before the test cases of that group execute. It executes just once</em>.</li><li><em>@AfterGroups</em> — <em>The </em><em>@AfterGroups method in TestNG run after the test cases of that group execute. It executes only once</em>.</li></ul><h3>Hierarchy In TestNG Annotations</h3><ul><li>@BeforeSuite</li><li>@BeforeTest</li><li>@BeforeClass</li><li>@BeforeMethod</li><li>@Test</li><li>@AfterMethod</li><li>@AfterClass</li><li>@AfterTest</li><li>@AfterSuite</li></ul><p><em>If there are multiple </em><em>@Test cases, TestNG runs the test cases in the alphabetical order.</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=676f11e922b2" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>