<?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 Alex Rodriguez on Medium]]></title>
        <description><![CDATA[Stories by Alex Rodriguez on Medium]]></description>
        <link>https://medium.com/@alex_rodriguez_soto?source=rss-87c96085ecee------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*BHabVjmumH7l6UoB2YW9UA.jpeg</url>
            <title>Stories by Alex Rodriguez on Medium</title>
            <link>https://medium.com/@alex_rodriguez_soto?source=rss-87c96085ecee------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Thu, 19 Nov 2026 22:20:23 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@alex_rodriguez_soto/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[Building a JSON Formatter with Python & DeepSeek AI]]></title>
            <link>https://medium.com/@alex_rodriguez_soto/building-a-json-formatter-with-python-deepseek-ai-460e8d45790c?source=rss-87c96085ecee------2</link>
            <guid isPermaLink="false">https://medium.com/p/460e8d45790c</guid>
            <category><![CDATA[qa]]></category>
            <category><![CDATA[deepseek]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[manual-testing]]></category>
            <dc:creator><![CDATA[Alex Rodriguez]]></dc:creator>
            <pubDate>Fri, 31 Jan 2025 21:41:21 GMT</pubDate>
            <atom:updated>2025-01-31T21:41:21.511Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*dc_zY6Grxe_v-V_X" /><figcaption>DeepSeek meets Python</figcaption></figure><p>I’ve tried so many online JSON formatters, but none of them ever felt <em>just right</em>. You know how it is — clunky interfaces, questionable privacy, and features that don’t quite match what you need. That’s why I decided to take matters into my own hands and build my own.</p><p>With the support of <strong>DeepSeek</strong>, I created a simple, offline application that does exactly what I want — no ads, no data exposure, just a clean and efficient way to format JSON. 🛠️✨</p><p>It was 1 in the morning and I decided to search the capabilities of DeepSeek and started adding some details of what I wanted.</p><p>Although my application it’s so basic, I was genuinely impressed by what can be achieved — and learned — with the support of AI. This project has become a tool I use daily to simplify my life, especially since I love exploring new tools, languages, and perspectives. It’s amazing how something so simple can spark so much curiosity and growth.</p><p>#AI #LearningJourney #LifeHacks #ExploreAndCreate #JSON #PrivacyMatters #DeepSeek #BuildYourOwn #DeveloperTools</p><p>Repository for Application</p><p><a href="https://github.com/edu-tech-opensource/json4Mter">GitHub - edu-tech-opensource/json4Mter</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*lECjg6B0Hj40JJ1LqOwdMA.png" /></figure><h3>The process..</h3><p>Key Features Added</p><p><strong>Resizable Window:</strong></p><p>The main window and text areas are resizable, allowing users to adjust the size as needed.</p><p><strong>Search Highlight:<br></strong>The searched keyword is highlighted in yellow in the formatted JSON text area.</p><p><strong>Word Counter for Search:<br></strong>Displays the number of occurrences of the searched keyword.</p><p><strong>Download Formatted JSON:<br></strong>Allows the user to save the formatted JSON to a file.</p><p><strong>Side-by-Side Layout:<br></strong>The left side displays the original/uploaded JSON, and the right side displays the formatted JSON.</p><h3>Features of the UI</h3><p><strong>Open JSON File</strong>: Load a JSON file from your local system.</p><p><strong>Format JSON</strong>: Pretty-print the JSON data.</p><p><strong>Search JSON:</strong> Search for a specific key in the JSON data.</p><p><strong>Download JSON</strong>: Download JSON from a URL.</p><p><strong>Upload JSON:</strong> Upload JSON data to a server.</p><h3>Some issues found along the way</h3><p>As I was testing the application I realized that some features were missing or not working as expected so I implemented those changes with the help of DeepSeek</p><p><strong>Copy-Paste JSON</strong>: Users can now paste JSON directly into the “Original/Uploaded JSON” text area.</p><p><strong>Preserve Original JSON</strong>: The original JSON remains unchanged when uploading or formatting.</p><p><strong>Clear Results:</strong> Added a “Clear Results” button to reset both text areas and clear the search highlights.</p><p><strong>Proper JSON Serialization</strong>:<br>The json.dumps() method is used with ensure_ascii=False to ensure that JSON is serialized with double quotes (“) and handles non-ASCII characters properly.</p><p><strong>Display JSON Correctly:</strong><br>The JSON data is displayed in the UI using pformat() and json.dumps(), ensuring that double quotes are preserved.</p><p><strong>Upload JSON with Double Quotes:</strong><br>When uploading JSON, the json.dumps() method ensures that the data is serialized with double quotes before being sent to the server.</p><p>I’ve loved using AI to create simple tools that make life easier. This journey has been both fun and inspiring, and I’m excited to take on more projects and explore new ideas. Let’s build something great together!</p><p>Follow me for more..</p><p><a href="https://admiralcoder.com/">https://admiralcoder.com/</a></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=460e8d45790c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Unlocking the Potential: My First Raspberry Pi Endeavor]]></title>
            <link>https://medium.com/@alex_rodriguez_soto/unlocking-the-potential-my-first-raspberry-pi-endeavor-14cb8ce53fb1?source=rss-87c96085ecee------2</link>
            <guid isPermaLink="false">https://medium.com/p/14cb8ce53fb1</guid>
            <category><![CDATA[raspberry-pi]]></category>
            <category><![CDATA[qa]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[linux]]></category>
            <dc:creator><![CDATA[Alex Rodriguez]]></dc:creator>
            <pubDate>Tue, 21 Nov 2023 21:06:38 GMT</pubDate>
            <atom:updated>2023-11-21T21:06:38.035Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g-YlepqkYlbF1pAZStAJlw.png" /></figure><p>Intro:<br>Let’s dive into the exciting world of Raspberry Pi with my first project!</p><p>After purchasing my first Raspberry Pi, I installed the Raspberry Pi OS and jumped into the world of microcomputing.</p><p>This journey began with a series of simple ideas that were shared by team members to be more specific my Development team. Hearing them talking about their projects raised my interest.</p><p>I started with the installation process, which demonstrates the ease of use of the Raspberry Pi operating system.</p><p>You worked through the setup wizard, configuring what you needed and choosing settings that suited your project’s needs.</p><p>Thanks to a smooth installation process, the Raspberry Pi was up and running in no time, opening the door to a variety of creative endeavors.</p><p>One of the great benefits of the Raspberry Pi OS is its versatility.</p><p>After a couple hours of use I can share that this operating system is tailored for education, programming, and DIY projects and provides a solid foundation for users of all experience levels.</p><p>What comes next? I am debating between considering a coding project, building a media center, or setting up a home automation system since Raspberry Pi’s adaptability makes it to bring some ideas to life.</p><p>Join me on this exciting journey..</p><h3>High Level Steps I followed</h3><ol><li>Prepare Your SD Card:</li><li>Obtain a microSD card (at least 8GB recommended) and insert it into your computer using an SD card adapter.</li><li>Download and install a tool like “Raspberry Pi Imager” (available from the official Raspberry Pi website).</li><li>Download Raspberry Pi OS:</li><li>Open the Raspberry Pi Imager.</li><li>Click on “Choose OS” and select “Raspberry Pi OS” from the list.<br>Select SD Card:<br>Click on “Choose SD Card” and select the microSD card you inserted.</li><li>Write the Image:<br>Click on “Write” to start the process. This will download the OS image and write it to your microSD card.</li><li>Eject the SD Card:<br>Once the process is complete, safely eject the microSD card from your computer.</li><li>Insert the SD Card into Raspberry Pi:<br>Carefully insert the microSD card into the slot on your Raspberry Pi.</li><li>Power Up Your Raspberry Pi:</li><li>Connect the power supply to your Raspberry Pi.</li><li>Follow On-Screen Instructions:</li><li>Raspberry Pi will boot up, and you’ll see the setup wizard.</li><li>Follow the on-screen instructions to configure language, time zone, and other preferences.</li><li>Update and Upgrade:<br>After the initial setup, it’s a good idea to open the terminal and run the following commands:</li></ol><pre><br>sudo apt update <br>sudo apt upgrade</pre><p>Reboot:</p><p>Finally, reboot your Raspberry Pi to apply any updates.</p><p><strong>Image support:</strong></p><p>Downloads:<br>Using MacOS to test this Download Rasberry Pi Imager</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*6iLhFwiizWsIHPnXcJhUXw.png" /></figure><p>Select Pi Device -&gt; Operating System -&gt; Storage (this is optional based on what you want</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k-dPAv57w49pzVCu23qzbQ.png" /></figure><p>Please follow me to see my next project. I rate this a 9/10 Simple and easy to install and set up my first raspberry Project.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=14cb8ce53fb1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Postman Visualize Reports]]></title>
            <link>https://medium.com/@alex_rodriguez_soto/postman-visualize-reports-d410e0ef4876?source=rss-87c96085ecee------2</link>
            <guid isPermaLink="false">https://medium.com/p/d410e0ef4876</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[qa]]></category>
            <category><![CDATA[automation-testing]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[postman]]></category>
            <dc:creator><![CDATA[Alex Rodriguez]]></dc:creator>
            <pubDate>Sat, 21 Oct 2023 06:06:23 GMT</pubDate>
            <atom:updated>2023-10-21T06:06:23.820Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*yo33tQegFoSBR6V_fflCCA.png" /><figcaption>Add Graphs, Tables, statistics to your postman response body Visualize</figcaption></figure><p>“Visualization is not necessary for every scenario, but when it is, here’s how you can get started in Postman.”</p><p>Introduction: Postman Visualizer offers a clear advantage when it comes to reporting the number of failed versus completed jobs, enhancing visibility and insights into your API testing results.</p><h4>Where can I use a visualize Scenario?</h4><p><strong>Healthcare</strong>: Visualize complex healthcare data and API responses to monitor patient records, treatment histories, or lab results, making it easier to ensure data accuracy and compliance.</p><p><strong>Finance</strong>: Analyze financial data, transactions, and security-related information with graphical representations, helping you detect anomalies and ensure data integrity.</p><p><strong>Statistics</strong>: Visualize statistical data for improved comprehension, enabling the examination of trends, outliers, and distributions, which is essential for data analysis and quality assurance.</p><p><strong>E-commerce</strong>: Monitor e-commerce API responses and sales data through visualization, making it simpler to identify issues related to product catalogs, order processing, or payment transactions.</p><p><strong>Data Validation</strong>: Verify and validate API responses visually, ensuring that the data matches the expected format and values, which is crucial for maintaining data quality.</p><p><strong>Comparative Analysis</strong>: Compare API responses across different endpoints or versions, aiding in version control and regression testing.</p><p><strong>Customized Reporting</strong>: Create customized, visually appealing reports for stakeholders, making it easier to communicate testing results and insights.</p><p><strong>Efficient Debugging</strong>: Diagnose issues faster by visualizing the response body, pinpointing errors, and improving the debugging process.</p><p><strong>Trend Analysis</strong>: Spot trends and patterns in API responses over time, which is valuable for performance analysis and optimization.</p><h4>Let us now write one table that displays the results and another table that shows a percentage of jobs for users with the status true vs false.</h4><ul><li>We will use this API endpoint /<em>Activities</em> that returns a response body that contains the following Response body.</li></ul><pre>// Import this curl command into your postman UI<br><br>curl --location &#39;https://fakerestapi.azurewebsites.net/api/v1/Activities&#39; \<br>--header &#39;Accept: text/plain; v=1.0&#39;<br><br>// Response Body will be an array<br><br>[<br>    {<br>        &quot;id&quot;: 1,<br>        &quot;title&quot;: &quot;Activity 1&quot;,<br>        &quot;dueDate&quot;: &quot;2023-10-21T05:22:55.25403+00:00&quot;,<br>        &quot;completed&quot;: false<br>    }<br>]</pre><p>This GET request contains an array of Id, title, dueDate and completed status.</p><p><em>Scenario</em>: You’re working on the order fulfillment system for an e-commerce platform. Each order may consist of various activities like packaging, shipping, and delivery. The JSON data contains details about these order activities.</p><p><em>Table Purpose</em>: The table shows the completion status of each order’s activities, helping the logistics team ensure that orders are being processed efficiently. The percentage of completed activities offers insights into order fulfillment progress.</p><p>Navigate to <strong>Postman</strong> &gt; <strong>Tests</strong> tab<br>let us discuss what we are doing here in order to achieve this <strong>GOAL</strong>:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*A_oHmCuv2wKiF16GbENxzA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*F8J1GnrARmCaYITuYuxv5w.png" /></figure><p>Let&#39;s now copy this code into your Postman Tests and <strong>Send</strong> the request.</p><p>Description to understand is provided inside the code and commented out with //</p><pre>// Parse the response JSON<br>var responseData = pm.response.json();<br><br>// Initialize variables to count completed tasks<br>var completedCount = 0;<br><br>// Used to calculate the total number of tasks in the response data<br>var totalTasks = responseData.length;<br><br>// Initialize an HTML table for response data<br>// The variable tableHTML is used to construct and store the <br>// HTML content for the table that displays the response data<br>var tableHTML = `<br>&lt;!DOCTYPE html&gt;<br>&lt;html&gt;<br>&lt;head&gt;<br>    &lt;style&gt;<br>        table {<br>            font-family: Arial, sans-serif;<br>            border-collapse: collapse;<br>            width: 100%;<br>        }<br>        <br>        th, td {<br>            border: 1px solid #dddddd;<br>            text-align: left;<br>            padding: 8px;<br>        }<br>        <br>        tr:nth-child(even) {<br>            background-color: #f2f2f2;<br>        }<br>    &lt;/style&gt;<br>&lt;/head&gt;<br>&lt;body&gt;<br>    &lt;h2&gt;Response Data&lt;/h2&gt;<br>    &lt;table&gt;<br>        &lt;tr&gt; <br>            &lt;th&gt;ID&lt;/th&gt;<br>            &lt;th&gt;Title&lt;/th&gt;<br>            &lt;th&gt;Completed&lt;/th&gt;<br>        &lt;/tr&gt;<br>`;<br><br>// Add data rows to the HTML table using forEach to iterate responseData<br>responseData.forEach(item =&gt; {<br>    tableHTML += `<br>        &lt;tr&gt;<br>            &lt;td&gt;${item.id}&lt;/td&gt;<br>            &lt;td&gt;${item.title}&lt;/td&gt;<br>            &lt;td&gt;${item.completed}&lt;/td&gt;<br>        &lt;/tr&gt;<br>    `;<br><br>    // Count completed tasks<br>    // completedCount++ is a way to increase that counter by one.<br>    if (item.completed === true) {<br>        completedCount++;<br>    }<br>});<br><br>// Close the HTML table for response data<br>// tableHTML is a variable that holds some text or HTML code.<br>// += means to add more content to what&#39;s already in the variable.<br><br>tableHTML += `<br>    &lt;/table&gt;<br>&lt;/body&gt;<br>&lt;/html&gt;<br>`;<br><br>// Calculate percentage of completed tasks<br>// Explanation provided under More Details<br>var completedPercentage = (completedCount / totalTasks) * 100;<br><br>// Var notCompletedPercentage = 100 - completedPercentage; <br>// is calculating the percentage of tasks that have not completed<br>// Explanation provided under More Details<br>var notCompletedPercentage = 100 - completedPercentage;<br><br>// Initialize an HTML table for completed and not completed percentages<br>var percentageTableHTML = `<br>&lt;table&gt;<br>    &lt;tr&gt;<br>        &lt;th&gt;Category&lt;/th&gt;<br>        &lt;th&gt;Count&lt;/th&gt;<br>        &lt;th&gt;Percentage&lt;/th&gt;<br>    &lt;/tr&gt;<br>    &lt;tr&gt;<br>        &lt;td&gt;Completed&lt;/td&gt;<br>        &lt;td&gt;${completedCount}&lt;/td&gt;<br>        &lt;td&gt;${completedPercentage.toFixed(2)}%&lt;/td&gt; <br>    &lt;/tr&gt;<br>    &lt;tr&gt;<br>        &lt;td&gt;Not Completed&lt;/td&gt;<br>        &lt;td&gt;${totalTasks - completedCount}&lt;/td&gt;<br>        &lt;td&gt;${notCompletedPercentage.toFixed(2)}%&lt;/td&gt;<br>    &lt;/tr&gt;<br>&lt;/table&gt;<br>`;<br>// Set the content for the Postman visualizer, which displays the <br>// tableHTML (response data) and percentageTableHTML (percentage statistics) <br>// together.<br>pm.visualizer.set(tableHTML + percentageTableHTML);</pre><h4>More Details</h4><pre>Explanation for:<br>       &lt;td&gt;${completedPercentage.toFixed(2)}%&lt;/td&gt; <br><br>it&#39;s formatting the value of completedPercentage with two <br>decimal places and adding a percentage sign (%).<br>results: 40.00%<br>----------------------------------------------------------------------------<br><br>Explanation for: <br>       var completedPercentage = (completedCount / totalTasks) * 100; <br><br>Suppose you have a list of tasks you need to complete, <br>and you want to calculate the percentage of tasks you&#39;ve finished. <br>Let&#39;s use the following numbers:<br><br>completedCount is the number of tasks you&#39;ve completed. <br>For this example, let&#39;s say you&#39;ve completed 20 tasks.<br><br>totalTasks is the total number of tasks in your list, <br>including those you&#39;ve completed and those you haven&#39;t. <br>Let&#39;s say there are 50 tasks in total.<br><br>Now, let&#39;s calculate the percentage of tasks completed:<br><br>(completedCount / totalTasks) calculates the fraction of <br>tasks you&#39;ve completed out of the total. In our example, <br>it&#39;s 20 / 50, which equals 0.4.<br><br>(0.4) * 100 multiplies this fraction by 100 to convert it into a percentage. <br>So, 0.4 * 100 equals 40.<br><br>So, (completedCount / totalTasks) * 100 is a way to find out that you&#39;ve <br>completed 40% of the tasks on your list.<br><br>In summary, if you&#39;ve completed 20 out of 50 tasks, the expression <br>(completedCount / totalTasks) * 100 helps you calculate that you&#39;ve <br>completed 40% of the tasks.<br><br>----------------------------------------------------------------------------<br><br>Explanation for:<br>       var notCompletedPercentage = 100 - completedPercentage; <br><br>Suppose you have the following data:<br><br>completedPercentage is 40%. This means you&#39;ve completed 40% of the tasks.<br>To calculate the notCompletedPercentage, you can use the expression <br>100 - completedPercentage:<br><br>100 represents 100% because you want to find the percentage of tasks <br>that are not completed.<br><br>completedPercentage is 40%.<br><br>So, 100 - 40 equals 60. This means that 60% of the tasks have not been <br>completed.<br><br>In simple terms, var notCompletedPercentage = 100 - completedPercentage; <br>calculates the percentage of tasks that are not completed by finding the <br>difference between 100% (all tasks) and the percentage of completed tasks.</pre><h4>In summary</h4><p>There is a lot you can do inside Postman Tests all you need to do is find a good scenario that you think brings value to your project and collections of APIs and start implementing.</p><p>This is a simple scenario but effective. You can customize based on your HTML experience and add Graphs, Tables and more..</p><blockquote>Don&#39;t forget to share with your friends and give me some thumbs up if you like the content and want more examples.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d410e0ef4876" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Step-by-step guide to running newman tests]]></title>
            <link>https://medium.com/@alex_rodriguez_soto/step-by-step-guide-to-running-newman-tests-8f990a639343?source=rss-87c96085ecee------2</link>
            <guid isPermaLink="false">https://medium.com/p/8f990a639343</guid>
            <category><![CDATA[development]]></category>
            <category><![CDATA[postman]]></category>
            <category><![CDATA[qa]]></category>
            <category><![CDATA[automation-testing]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Alex Rodriguez]]></dc:creator>
            <pubDate>Tue, 13 Jun 2023 20:39:20 GMT</pubDate>
            <atom:updated>2023-06-13T20:39:20.223Z</atom:updated>
            <content:encoded><![CDATA[<p>Step-by-step guide to running newman tests</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*HnVHk2FnTfpkqRmzXstFUw.png" /></figure><p>Table of content:<br><strong>1</strong>. <a href="#4cb5"><strong>Install Newman by running the following command in your terminal</strong></a><strong><br>2. </strong><a href="#906b"><strong>Create a JSON file</strong></a><strong><br>3. </strong><a href="#f3f1"><strong>Create Environment Variables</strong></a><strong><br>4. </strong><a href="#9bd1"><strong>Execute Collections using newman</strong></a><strong><br>5. </strong><a href="#f1cd"><strong>Results in terminal</strong></a><strong><br>6. </strong><a href="#a92a"><strong>Execute newman with environment variables</strong></a><strong><br>7. </strong><a href="#6b72"><strong>Running single folders in collections</strong></a><strong><br>8. </strong><a href="#f043"><strong>Using data (csv)</strong></a><strong><br>9. </strong><a href="#60a4"><strong>Setting variables</strong></a><strong><br>10. </strong><a href="#9278"><strong>Generating reports</strong></a><strong><br>11. </strong><a href="#e738"><strong>Running a collection multiple times (Iteratations)</strong></a><strong><br>12. </strong><a href="#ea9c"><strong>Running a collection with a custom timeout</strong></a></p><p><em>Newman is a Postman companion with a command-line interface (CLI) that lets you run collections and tests from the command line. Your Postman collections can be easily automated and integrated into your continuous integration/continuous delivery (CI/CD) pipeline with Newman.</em></p><p><em>Newman’s ability to produce reports in a variety of formats, including JSON, HTML, and JUnit, is one of its advantages. This makes it simple to track your progress over time and share test results with your team.</em></p><p><em>Newman can be used to execute individual Postman requests or even a subset of requests within a collection in addition to running collections. This adaptability makes Newman a useful asset for testing APIs and microservices.</em></p><p>In general, Newman is an important expansion to any Programming interface testing tool compartment. Newman can assist you in streamlining your testing and integrating it into your development workflow thanks to its adaptability, robust reporting capabilities, and ease of use.</p><h3>Lets get started</h3><p>— — — — — — — — — — REPOSITORY — — — — — — — — — — — — — — — —</p><p><strong><em>Use this API collection if you don’t have any. </em></strong><br>Repository:<br><a href="https://github.com/alexrodriguezsoto/apiTest.git">https://github.com/alexrodriguezsoto/workspace-project</a><br> — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — — —</p><p>Here’s an example of how to get started with Newman commands:</p><ol><li><strong>Install Newman by running the following command in your terminal:</strong></li></ol><p>Install Node.js: Newman is a command-line tool that runs on Node.js. If you don’t have Node.js installed, you need to download and install it on your system. Visit the official Node.js website (<a href="https://nodejs.org/">https://nodejs.org</a>) and download the appropriate installer</p><pre>node -v</pre><p>This command should display the installed version of Node.js, confirming that the installation was successful.</p><pre>npm install -g newman</pre><p>This command will download and install the latest version of Newman globally on your system. The -g flag ensures that Newman is installed as a global package, making it accessible from any directory.</p><p>2. <strong>Create Collections</strong><br>Create a JSON file of your Postman collection. In the Postman app, you can accomplish this by selecting “Collection” as the export format and clicking the “Export” button.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/959/1*3Y7Xe9Uib1EbhD6ZAtW2fA.png" /></figure><p>3. <strong>Create Environment Variables</strong><br>Save your environment Variables or use the environment variables provided in the example repository</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/841/1*XokfxZ3gRR5c1mssyoiB5A.png" /></figure><p>4. <strong>Execute Collections using newman</strong><br>To run your collection with Newman, run the following command:</p><pre>newman run &lt;collection.json&gt;</pre><p><em>Let’s try it out using workspace-project collections</em></p><pre>newman run Workspace.postman_collection.json</pre><p>The name of your JSON file should be used in place of “&lt;collection.json&gt;.”</p><p>5. <strong>Results in terminal</strong> <br>Your collection will be run by Newman, which will begin and display the results in your terminal. Newman will execute all of your requests and display the test results for each one by default.</p><p>Terminal Examples.</p><pre>┌─────────────────────────┬────────────────────┬────────────────────┐<br>│                         │           executed │             failed │<br>├─────────────────────────┼────────────────────┼────────────────────┤<br>│              iterations │                  1 │                  0 │<br>├─────────────────────────┼────────────────────┼────────────────────┤<br>│                requests │                  9 │                  0 │<br>├─────────────────────────┼────────────────────┼────────────────────┤<br>│            test-scripts │                 18 │                  1 │<br>├─────────────────────────┼────────────────────┼────────────────────┤<br>│      prerequest-scripts │                 13 │                  0 │<br>├─────────────────────────┼────────────────────┼────────────────────┤<br>│              assertions │                 43 │                  1 │<br>├─────────────────────────┴────────────────────┴────────────────────┤<br>│ total run duration: 1894ms                                        │<br>├───────────────────────────────────────────────────────────────────┤<br>│ total data received: 1.92kB (approx)                              │<br>├───────────────────────────────────────────────────────────────────┤<br>│ average response time: 184ms [min: 91ms, max: 809ms, s.d.: 221ms] │<br>└───────────────────────────────────────────────────────────────────┘</pre><pre>  #  failure                detail</pre><pre> 1.  AssertionError         Status code is 200<br>                            expected response to have status code 200 but got 400<br>                            at assertion:0 in test-script<br>                            inside &quot;users / login upload&quot;</pre><pre> 2.  TypeError              Cannot read properties of undefined (reading &#39;token&#39;)<br>                            at test-script<br>                            inside &quot;users / login upload&quot;</pre><p>6. <strong>Execute newman with environment variables</strong><br>By adding various options, such as specifying an environment file, using data files, or setting variables, you can customize your Newman command. Use the following command, for instance, to run your collection with a particular environment file:</p><pre>newman run &lt;collection.json&gt; -e &lt;environment.json&gt;</pre><p><em>Let’s try it out using workspace-project collections</em></p><pre>newman run Workspace.postman_collection.json -e QAEnv.postman_environment.json</pre><p>The name of your environment file should be substituted for “&lt;environment.json&gt;.”</p><p>A few examples of how to use Newman commands include the ones listed here. For more data on the most proficient method to utilize Newman, including a full rundown of accessible choices and models, allude to the Newman documentation.</p><p>7. <strong>Running single folders in collections</strong></p><pre>newman run &lt;collection.json&gt; -e &lt;environment.json&gt; --folder &quot;&lt;folder-name&gt;&quot;</pre><p><em>Let’s try it out using workspace-project collections</em></p><pre>newman run Workspace.postman_collection.json  -e QAEnv.postman_environment.json --folder &quot;users&quot;</pre><p>The name of the folder containing the request and the name of the request should be substituted for “&lt;folder-name&gt;.”</p><p>8. <strong>Using data (csv)</strong></p><pre>newman run &lt;collection.json&gt; -d &lt;data-file.csv&gt;</pre><p>Replace &lt;data-file.csv&gt; with the name of your data file.</p><p><em>Let’s try it out using workspace-project collections</em></p><pre>newman run Workspace.postman_collection.json -e QAEnv.postman_environment.json <br>--folder &quot;users&quot; -d creden.csv     <br> <br>Example results:            <br>newman</pre><pre>workSpace</pre><pre>❏ users<br>↳ login upload<br>  POST <a href="https://api.octoperf.com/public/users/login?username=tla.jiraone@gmail.com&amp;password=test12">https://api.octoperf.com/public/users/login?username=tla.jiraone@gmail.com&amp;password=test12</a> [200 OK, 570B, 373ms]<br>  ✓  Status code is 200</pre><pre>↳ currentUser<br>  GET <a href="https://api.octoperf.com/users/current">https://api.octoperf.com/users/current</a> [200 OK, 837B, 97ms]<br>  ✓  Status code is 200 for /public/users/login<br>  ✓  Status code name has string OK<br>  ✓  verify content type is Json body for [login]</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/420/1*TnGyY297zmXPvWIbNs68ow.png" /></figure><p><strong>9. Setting variables</strong></p><p>Setting variables in Newman allows you to define and manage dynamic values that can be used throughout your API testing collection runs. Variables provide flexibility and enable you to customize your requests, headers, or any other part of your API tests based on different scenarios or environments.</p><ol><li>Global Variables: Global variables are similar to environment variables, but they are available throughout the entire collection run. Global variables can be set using the -g or --globals flag, followed by a JSON or CSV file containing the variable key-value pairs.</li><li>Collection Variables: You can also define variables specific to individual requests within your collection. These variables are stored within the collection itself and can be accessed only by the associated request.</li></ol><pre>newman run collection.json -g globals.json</pre><pre>newman run &lt;collection.json&gt; --global-var &quot;variable-name=value&quot; --env-var &quot;variable-name=value&quot;</pre><pre>&quot;variables&quot;: [<br>  {<br>    &quot;key&quot;: &quot;baseURL&quot;,<br>    &quot;value&quot;: &quot;https://api.example.com&quot;<br>  },<br>  {<br>    &quot;key&quot;: &quot;token&quot;,<br>    &quot;value&quot;: &quot;your-auth-token&quot;<br>  }<br>]</pre><ul><li>--env-var &quot;variable-name=value&quot;: This flag is used to set an environment variable in Newman. Environment variables are specific to a particular environment and can be accessed across different requests within the collection run. You can specify the name of the variable and its corresponding value using the format &quot;variable-name=value&quot;.</li></ul><p>Example: --env-var &quot;token=your-auth-token&quot;</p><p>By using the --global-var and --env-var flags, you can pass custom variable values to your collection during the Newman run</p><p><strong>10. Generating reports</strong></p><pre>newman run &lt;collection.json&gt; --reporters cli,json,html</pre><p>This command generates test results in CLI, JSON, and HTML formats.</p><p><em>Let’s try it out using workspace-project collections</em></p><pre>newman run Workspace.postman_collection.json<br>-e QAEnv.postman_environment.json <br>-r htmlextra --reporter-htmlextra-export ./Downloads/htmlreport.html</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*TWwJPvUIv3HFdQtNPbVjiA.png" /></figure><p>Newman Workspace.postman_collection.json: This command executes a Postman collection named Workspace.postman_collection.json using Newman.</p><p>-e QAEnv.postman_environment.json: The -e option specifies the environment file to use during compilation. In this case, the environment file QAEnv.postman_environment.json contains variables and values ​​related to the QA environment. Newman uses these variables when running the collection, allowing for flexibility for different environments.</p><p>-r htmlextra: The -r option specifies the type of reporter used to generate the report. In this case, the htmlextra reporter is selected. This is Newman’s extended HTML reporter that provides comprehensive and visually appealing HTML reporting.</p><p>- -reporter-htmlextra-export ./Downloads/htmlreport.html: This option specifies the file path (./Downloads/htmlreport.html) where the HTML report is exported and saved. In this example, the report is saved in the downloads folder as htmlreport.html.</p><p>An open-source reporting tool for Postman’s API testing tool, Newman HTML Extra reporter offers interactive features, enhanced HTML reporting capabilities, and support for custom templates.</p><ol><li>Generate a basic HTML report for a collection run:</li></ol><pre>newman run collection.json -r htmlextra</pre><p>2. Generate an HTML report with additional information like environment variables and request headers:</p><pre>newman run collection.json -r htmlextra --reporter-htmlextra-export report.html --reporter-htmlextra-title &quot;API Test Report&quot; --reporter-htmlextra-showEnvironmentData --reporter-htmlextra-showHeaders</pre><p>3. Generate an HTML report with a custom title:</p><pre>newman run collection.json -r htmlextra --reporter-htmlextra-export report.html --reporter-htmlextra-title &quot;API Test Report&quot;</pre><p>4. Generate an HTML report with multiple reporters:</p><pre>newman run collection.json -r cli,htmlextra --reporter-cli-no-failures --reporter-htmlextra-export report.html --reporter-htmlextra-title &quot;API Test Report&quot;</pre><p>11. <strong>Running a collection multiple times (Iteratations)</strong></p><pre>newman run &lt;collection.json&gt; -n &lt;number-of-iterations&gt;</pre><pre>newman run Workspace.postman_collection.json  -e QAEnv.postman_environment.json -n 2                                  ─╯<br>newman</pre><p><em>Let’s try it out using workspace-project collections</em></p><pre>┌─────────────────────────┬────────────────────┬───────────────────┐<br>│                         │           executed │            failed │<br>├─────────────────────────┼────────────────────┼───────────────────┤<br>│              iterations │                  2 │                 0 │<br>├─────────────────────────┼────────────────────┼───────────────────┤<br>│                requests │                 18 │                 0 │<br>├─────────────────────────┼────────────────────┼───────────────────┤<br>│            test-scripts │                 36 │                 2 │<br>├─────────────────────────┼────────────────────┼───────────────────┤<br>│      prerequest-scripts │                 26 │                 0 │<br>├─────────────────────────┼────────────────────┼───────────────────┤<br>│              assertions │                 86 │                 2 │<br>├─────────────────────────┴────────────────────┴───────────────────┤<br>│ total run duration: 2.7s                                         │<br>├──────────────────────────────────────────────────────────────────┤<br>│ total data received: 3.83kB (approx)                             │<br>├──────────────────────────────────────────────────────────────────┤<br>│ average response time: 129ms [min: 93ms, max: 435ms, s.d.: 79ms] │<br>└──────────────────────────────────────────────────────────────────┘</pre><ul><li>newman run Workspace.postman_collection.json: This command runs the Postman collection named Workspace.postman_collection.json using Newman. It executes the requests and tests defined within the collection.</li><li>-e QAEnv.postman_environment.json: The -e option specifies the environment file to be used during the collection run. In this case, the environment file QAEnv.postman_environment.json contains variables and values specific to the QA environment. Newman will utilize these variables while running the collection, enabling flexibility and adaptability across different environments.</li><li>-n 2: The -n option specifies the number of iterations for the collection run. In this example, the value is set to 2, indicating that the collection will be executed twice.</li></ul><p>12. <strong>Running a collection with a custom timeout</strong></p><pre>newman run &lt;collection.json&gt; --timeout-request &lt;timeout-in-ms&gt;</pre><p><em>Let’s try it out using workspace-project collections</em></p><pre>newman run Workspace.postman_collection.json <br>-e QAEnv.postman_environment.json --timeout-request 10</pre><pre>-- ERROR generated by timeout --</pre><pre>❏ users<br>↳ login upload<br>  POST <a href="https://api.octoperf.com/public/users/login?username={{user}}&amp;password={{pass}}">https://api.octoperf.com/public/users/login?username={{user}}&amp;password={{pass}}</a> [errored]<br>     ETIMEDOUT</pre><ul><li>newman run Workspace.postman_collection.json: This command runs the Postman collection named Workspace.postman_collection.json using Newman. It executes the requests and tests defined within the collection.</li><li>-e QAEnv.postman_environment.json: The -e option specifies the environment file to be used during the collection run. In this case, the environment file QAEnv.postman_environment.json contains variables and values specific to the QA environment. Newman will utilize these variables while running the collection, enabling flexibility and adaptability across different environments.</li><li>--timeout-request 10: The --timeout-request option sets the maximum time allowed for each individual request to complete. In this example, the value is set to 10 milliseconds. If a request exceeds this timeout, Newman will consider it as failed.</li></ul><p>Newman is a powerful command-line tool for running Postman collections, providing benefits such as automation, easy integration into CI/CD pipelines, and the ability to execute tests in parallel. It helps streamline API testing and offers detailed reporting. Learn more about Newman at: <a href="https://learning.postman.com/docs/collections/using-newman-cli/command-line-integration-with-newman/">https://learning.postman.com/docs/collections/using-newman-cli/command-line-integration-with-newman/</a></p><p>Learn more: <a href="https://quickstarts.postman.com/">https://quickstarts.postman.com/</a></p><blockquote>Don’t forget to follow for more details.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=8f990a639343" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Performance Test with Postman Canary]]></title>
            <link>https://medium.com/@alex_rodriguez_soto/performance-test-with-postman-canary-322470c369b1?source=rss-87c96085ecee------2</link>
            <guid isPermaLink="false">https://medium.com/p/322470c369b1</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[performance-testing]]></category>
            <category><![CDATA[postman]]></category>
            <category><![CDATA[load-testing]]></category>
            <category><![CDATA[testing]]></category>
            <dc:creator><![CDATA[Alex Rodriguez]]></dc:creator>
            <pubDate>Mon, 15 May 2023 05:25:25 GMT</pubDate>
            <atom:updated>2023-05-15T13:46:04.178Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*uHFsPLgYMQ8KHLDR" /><figcaption>Gas Station has 2 pumps that fill up a full tank in 1 minute = throughput is 2 per minute everyone else waits</figcaption></figure><blockquote>NOTE: Postman Canary is a <strong>preview</strong> version of the popular Postman API <strong>tester.</strong> It is <strong>intended</strong> for users who want to test the latest features and updates before they are officially released to the public. Canary releases are considered experimental and may contain bugs or other issues.</blockquote><p>Postman Canary offers a robust performance testing <strong>capability</strong> to simulate thousands of virtual users, <strong>find</strong> bottlenecks and optimize APIs to handle high traffic. It is ideal for developers and QA engineers to test and develop faster and <strong>more</strong> reliable APIs.</p><p>Now that we have introduced this cool feature let us look into it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dZBsk0I9O7jRoqBQoE_0CQ.png" /></figure><p>1- In Postman Canary’s performance testing feature, virtual users are simulated users that are used to test how an API performs under different load conditions.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/413/1*0Fzvi-NzynWHOmNSY7KZow.png" /></figure><p>2- The test duration is the amount of time that the performance test will run for.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/423/1*F7zw_xh3o2SaE3ZDFQ66FQ.png" /></figure><p>3- The <strong>Load Profile</strong> defines how the virtual users will interact with the API over the duration of the test.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/437/1*fSBawS2CiNFOJ33Nm_SoPw.png" /></figure><p>The “<strong>Fixed</strong>” option in the load profile means that the number of virtual users remains constant throughout the entire test duration.</p><p>The <strong>Load Profile - Ramp up </strong>option in Postman Canary performance testing allows users to gradually increase the number of virtual users over time. This means that the load on the API will slowly increase until it reaches the desired maximum number of virtual users. This option helps simulate a more realistic scenario where traffic increases gradually instead of a sudden traffic spike.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/599/1*vCXWmOSaGLBeqGj77S1LSw.png" /></figure><h3>EXAMPLE</h3><p>Let us now create a BenchMark where we will use a test API running in a local environment. <em>( PostgreSQL, Express, React, NodeJS )</em></p><pre>Sending a Post request to the endpoint /todos with JSON payload that<br>generates a 10 character random value<br><br>{<br> &quot;name_description&quot;:&quot;{{randomValue}}&quot;<br>}<br><br><br>curl --location &#39;http://localhost:4500/todos&#39; \<br>--header &#39;Content-Type: application/json&#39; \<br>--data &#39;{<br> &quot;name_description&quot;:&quot;{{randomValue}}&quot;<br>}&#39;</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/605/1*E-Sj5NJQbE7Eq88dwSf3KQ.png" /></figure><h3>Load Profile Fixed</h3><p>Scenario: <br>Execute <strong>2 Virtual Users</strong><br>test duration <strong>1 Minute</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KeaQjVUGJNVbveqH9d-VdQ.png" /></figure><h3>Let us evaluate the results:</h3><p><strong>Total Requests sent: </strong>108<br>Notes: Execute 2 users over a period of 1 minute</p><p><strong>Requests/s: </strong>1.72 requests/s<br>Notes: Remember there are factors that may affect the requests per second such as memory, network and other factors.</p><p><strong>Average Response Time</strong>: 8 ms<br>Notes: The average response time is calculated by <strong>adding up </strong>the response times of each request made during the test and then <strong>dividing by the total number of requests</strong>.</p><p><strong>Error Rate</strong>: 0%<br>Notes: If any of the requests returns other than status code 200 error is captured.</p><p>Getting a total count from PostgresSQL:</p><pre>SELECT count(*) FROM todo;<br><br>+=======+<br>+ count +<br>+=======+<br>+   108 +<br>+=======+<br></pre><p>Evaluating <strong>Performance details for a total duration</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*hfVSIl9mMb59xGAKgB214A.png" /></figure><p><strong>Min(ms)</strong>: 3<br>Notes: From all 108 requests one of the minimum requests that it took was 3(ms)</p><p><strong>Max(ms)</strong>: 24<br>Notes: From all 108 requests one of the max requests is 24(ms)</p><p><strong>90th(ms)</strong>: 12<br>Notes: The 90th percentile is the value below which 90% of the samples fall. This means that 10% of requests may have a longer response time than the reported 90th percentile. <br>For example, if a test reports a 90th percentile response time of 12 ms, this means that 90% of requests had a response time of 12 ms or less. The remaining 10 percent of requests may have a response time of more than 12 ms. In a real project, the 90th percentile is used to measure response time for most users.<strong> </strong>This helps developers and testers identify and optimize slow APIs and ensure that most requests have an acceptable response time. <br>For example, an e-commerce site can use the 90th percentile to ensure that most users can complete a transaction in a reasonable amount of time, thereby reducing the likelihood of cart abandonment and dissatisfied customers.</p><h3>Graph Metrics Filters</h3><h4><strong>Avg. response</strong></h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*KMlDhfpCJUx1nsg4asrAng.png" /></figure><h4>Min Response</h4><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*W1RMIjIEz0GQAOYGSNTxkA.png" /></figure><p><strong>Max response</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*aFIQBWIccykTlFHpYrqeFg.png" /></figure><p><strong>90th percentile</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*RakyqSFsxJ0rXOiLnWoJuA.png" /></figure><p><strong>Detail filter Graph</strong><br>- Virtual users — 10 requests<br>- Requests/s<br>- Avg. response<br>- Error rate</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Vn8t27bWKa6ipErIpYVNGA.png" /></figure><h4>Throughput</h4><p>Throughput refers to the number of requests processed by the server in a given time period. This is usually measured in requests per second (RPS) and is a key performance testing metric.</p><p>Throughput can help determine an API’s ability to handle requests under different load conditions and can be used to identify bottlenecks and areas for optimization.</p><p>High throughput indicates that the API can handle a large number of requests, while low throughput indicates that the API may be experiencing performance issues or may not be able to handle high volumes of traffic.</p><h4>Ramp Up Summary</h4><p><strong>Virtual Users</strong>: 10<br><strong>Test Duration</strong>: 2 mins<br><strong>Load Profile</strong> -&gt; <strong>Ramp up</strong>: 1 mins</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*GGOwoXCkZJe0CLV-wUhfFA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*fyDJc0MT_ZS6tDzo8DLTZw.png" /></figure><h4>Summary:</h4><p>Total <strong>number of requests</strong> 804 in a period of 2 minutes with 10 users<br><strong>Requests</strong> 6.49</p><p>The number of requests made during the test is determined by the load profile defined in the test configuration and the duration of the test. The load profile determines how many virtual users are simulated and how quickly they reach the specified load.</p><p>The test duration determines how long the test lasts. Based on these factors, Postman calculates and sends the appropriate number of requests to the API under test.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*wsXepuKBtmKo0ffCWqm1EA.png" /></figure><p><strong>Throughput</strong> can vary from one performance tester to another because it is affected by various factors such as load profile, number of virtual users, API response time, and corresponding payload size.</p><p>Therefore, performance may vary depending on these factors and it is important to consider them when analyzing performance test results.</p><h4>Errors and History for performance test</h4><p>The server crashed and therefore generated some errors a total of 4.79%.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*dNEKNq87NzcE-X-PNMzbcQ.png" /></figure><p>10% Error rate started happening for 10 requests and then followed by 100% Error for 13 requests The performance test continues but this analysis should be tracked to identify issues such as root cause for failure.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*N11hl43ZFruCXZZ9xhY71Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*L-ssz9nTlnhBfKDBrGxwyQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZNXG_C4kFDgwMyQlef2p5g.png" /></figure><h4>History for performance test execution under Performance runs</h4><p>This screen helps you track and analyze results for different fields such as:</p><p><strong>Total requests<br>Requests/s<br>Resp. Time(Avg ms)<br>Error %</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jcYu4_MeMvIeqqhOZak5fw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ZePPxpo36HkN_U1cLxAgiA.png" /></figure><h4>Closing statement</h4><p>In summary, Using Postman Canary for someone experienced in performance testing and API testing is not too hard to understand or evaluate. For someone with 0 experience hopefully, this documentation can help you understand some terminology used in performance testing.</p><p>Overall This documentation is mostly to introduce us to performance testing using Postman Canary. I am sure there is a lot of things coming up as improvements.</p><blockquote>If you enjoyed this content, I would appreciate if you took the time to check out my other works and follow me. Thank you for your support and I hope to continue providing valuable insights and information to help you with your projects.</blockquote><p>#performance #loadtesting #api #virtualusers #throughput #latency #response #scalability #loadtesting #stress testing #APItesting #performancetesting #loadsimulation #loadbalancing #serverperformance #responsemetrics #latencytesting #througputtesting #performanceoptimization</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=322470c369b1" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Integrate Postman with CircleCI]]></title>
            <link>https://medium.com/@alex_rodriguez_soto/circleci-postman-api-config-yml-gitlab-repository-9197d868bb22?source=rss-87c96085ecee------2</link>
            <guid isPermaLink="false">https://medium.com/p/9197d868bb22</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[ci-cd-pipeline]]></category>
            <category><![CDATA[circleci]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[postman]]></category>
            <dc:creator><![CDATA[Alex Rodriguez]]></dc:creator>
            <pubDate>Thu, 20 Apr 2023 05:13:09 GMT</pubDate>
            <atom:updated>2023-05-01T04:26:26.659Z</atom:updated>
            <content:encoded><![CDATA[<h3>CircleCI Postman API config.yml GitLab repository</h3><p># CircleCI # Postman #<a href="https://www.google.com/search?q=circle+ci+postman&amp;rlz=1C5CHFA_enUS994US994&amp;oq=circle+ci++postman&amp;aqs=chrome..69i57j0i13i512j0i390i650l3j69i60l3.3187j0j7&amp;sourceid=chrome&amp;ie=UTF-8#ip=1">CI/CD</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/714/1*oP_0StSCRRDM2IqrBSB-KQ.jpeg" /></figure><p>CircleCI is a widely used CI/CD platform for automating build, test, and deployment processes. CircleCI, which works with a variety of languages and cloud platforms, lets teams find and fix bugs early in the software development cycle, ensuring that releases are reliable and effective.</p><p>In this instance we will create one for API. Where we will create a config.yml file and run it in CircleCI.</p><p>Content:</p><ol><li><a href="#ecdd">API Collections</a></li><li><a href="#dbe8">Gitlab repository</a></li><li><a href="#1210">confi.yml file create for Postman API test</a></li></ol><h4>API Collections</h4><ul><li>Swagger collections for project <a href="https://api.octoperf.com/swagger-ui/index.html#/">octoperf</a></li><li>Create a collection or use this collection which contains Test Scrips Create your own account for <a href="https://api.octoperf.com/app/#/access/signup">octoperf</a> make sure its a Test Account</li><li>Once you create you account and verify it you can use it in place of variables {{username}} and {{password}}</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bf4BO7sHLvZSlEGt7Dr6jQ.png" /></figure><h4>Gitlab Repository</h4><p>Push your collections and environment variables to gitlab repository or you can use this example.</p><p><a href="https://gitlab.com/circlecipostman/workspacecircleci">circleCIPostman / workspaceCircleCI · GitLab</a></p><p>Make sure to add a <strong>.circleci/config.yml</strong> to your repository as shown below</p><p>This CircleCI configuration file sets up a build job using the circleci/node:12 Docker image. The job has several steps:</p><ol><li>checkout: checks out the source code.</li><li>Install Dependencies: installs Newman, a popular Postman API testing tool, and its HTML Extra reporter plugin globally using npm.</li><li>Run Newman tests: runs Newman tests using a Postman collection (MultiManage_DEV.postman_collection.json) and an environment (devEnvironment.postman_environment.json) file. It exports the test results in HTML (target/testHtmldev.html) and JSON (target/testJsondev.json) formats using the HTML Extra and CLI reporters, and stores them as artifacts.</li><li>store_artifacts: stores the HTML test report in the reports/ directory and the JSON test results in the test-results/ directory.</li></ol><p>This configuration is designed to run Newman tests, generate test reports in HTML and JSON formats, and store the artifacts for further reference or analysis.</p><pre>version: 2<br>jobs:<br>  build:<br>    docker:<br>      - image: circleci/node:12<br>    steps:<br>      - checkout<br>      - run:<br>          name: Install Dependencies<br>          command: |<br>            sudo npm install -g newman<br>            sudo npm install -g newman-reporter-htmlextra<br>            npm install<br>      - run:<br>          name: Run Newman tests<br>          command: |<br>            newman run MultiManage_DEV.postman_collection.json -e devEnvironment.postman_environment.json -r htmlextra,cli,json --reporter-htmlextra-export target/testHtmldev.html --reporter-json-export target/testJsondev.json<br>      - store_artifacts:<br>          path: target/testHtmldev.html<br>          destination: reports/<br>      - store_artifacts:<br>          path: target/testJsondev.json<br>          destination: test-results/</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g66dskLes_a3bkZ_jpRU1g.png" /></figure><h4>Set up CircleCI confi.yml</h4><p>In order to run CircleCI for your postman collections you can use this template.</p><ol><li>Sign up with CircleCI select GitLab</li><li>sign in</li><li>Select <strong>Create New Organization</strong></li><li>Select GitLab under <strong>Connect to</strong></li><li><strong>Under Create New Project</strong> select Repository -&gt; for Select your config.yml file select Fastest -&gt; Select GitLab Project Name</li><li>If your .yml file is found under repository you will see. .circleci/config.yml found then click on <strong>Create Project</strong></li><li>Select Use <strong>Existing Config</strong></li><li>Press <strong>Start Building</strong></li><li>Then make a Commit to your repository to start the Pipeline</li><li>when your Build Completes Running you can click on <strong>Success</strong> and then <strong>build </strong>you will see STEPS, TESTS, TIMING, ARTIFACTS, RESOURCES</li><li>Under STEPS you can find console logs including newman run</li><li>Under ARTIFACTS you will find your postman collection reports.</li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*b9PTPHkpwF49xCnONT_hOA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/288/1*mBlDTr_Y0niGfLN7wppM8Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/582/1*TGUUylIC3UOWv9iSm1RMhw.png" /></figure><p><em>Example for a scenario where config.yml not found</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/652/1*qElE4XSGbEH3UGDUmRo9kA.png" /></figure><p><em>Example of repository with existing config.yml</em></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/549/1*oOjpANSY4M_--6qCLRQqxg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*atGtsUnojJTH_6vErPUTLw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/502/1*sQJd-IBEZG36AmZdfJOFIg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5foh9HR7MGDifmYhnCWLLA.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*k3k9Ud4F-0o8_9yYj7aWPg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*anbcXHxNou0nJG3E4RJLUg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/585/1*gKIF8F0b7Dm56SCl-sA8pg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Ew_fjZ29AXXuRTJkCOGFpA.png" /></figure><p>In conclusion, the combination of CircleCI, a popular continuous integration and continuous deployment (CI/CD) platform, and Postman, a widely-used API testing tool, can greatly enhance the development and testing workflow of API-driven applications. The YAML configuration files for CircleCI and Postman provide a powerful and flexible way to define build and test jobs, automate API testing, generate test reports, and store artifacts for further analysis.</p><blockquote>Please follow for more content like this.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=9197d868bb22" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[JMeter Using Variables]]></title>
            <link>https://medium.com/@alex_rodriguez_soto/jmeter-using-variables-60c4b0d52bb0?source=rss-87c96085ecee------2</link>
            <guid isPermaLink="false">https://medium.com/p/60c4b0d52bb0</guid>
            <category><![CDATA[software-testing]]></category>
            <category><![CDATA[quality-assurance]]></category>
            <category><![CDATA[jmeter]]></category>
            <category><![CDATA[load-testing]]></category>
            <category><![CDATA[performance-testing]]></category>
            <dc:creator><![CDATA[Alex Rodriguez]]></dc:creator>
            <pubDate>Sun, 09 Apr 2023 07:09:09 GMT</pubDate>
            <atom:updated>2023-04-26T03:29:18.571Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zuQmrSxmPOFGQhN7cbhN7A.png" /></figure><p>Example JMeter Collection: <a href="https://github.com/alexrodriguezsoto/JmeterCollections">https://github.com/alexrodriguezsoto/JmeterCollections</a></p><h3>Table of Content</h3><ol><li><a href="#20e7">Introduction</a></li><li><a href="#c162">Parameterization</a> — Reading from CSV file and use the variables</li><li><a href="#333a">Correlation</a> — Using BeanShell PostProcessor to save the Variable</li><li><a href="#e4a2">User Defined variables</a> — User Defined Variables</li></ol><h3>Introduction</h3><p>Throughout a JMeter test script, JMeter variables are used to store and retrieve values. They can be defined at the individual sampler, thread group, or test plan level.</p><p>In a JMeter script, variables can be used for the following things:</p><p><strong>Parameterization</strong>: Involving factors to supplant hard-coded values in demands, making it simple to test with various info values.</p><p><strong>Correlation</strong>: storing and utilizing values from server responses, such as tokens or session IDs, in subsequent requests.</p><p>Lets see it in Action:</p><h3><strong>Parameterization :</strong></h3><h3>Reading from CSV file and use the variables</h3><ol><li>First, create a CSV file containing data.</li><li>Create a CSV Data Set Config element for your test plan in JMeter. You can use data from the CSV file with this element in your test.</li><li>Make the CSV Data Set Config element so that it can read data from the CSV file that you created in step 1. The file path, delimiter, and other settings can be specified.</li><li>Use a JMeter variable in place of the username in your HTTP Request sampler. For instance, in the event that the item name field is label as username , you can supplant it with “${username}”.</li></ol><p>Example:</p><pre>// csv file comma separated contains username and password fields<br><br>demotest@email.com, pass123</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*BHp0ddQTpIeaty0WGIxhWQ.png" /></figure><h3>Assign Variable Names example: username, password</h3><blockquote>Here is a concise description of each field in the CSV Data Set Config</blockquote><blockquote><strong>Name</strong>: The name of the CSV Informational collection Config component.</blockquote><blockquote><strong>Filename</strong>: the name of the data-containing CSV file. This can be a relative or absolute path from the JMeter script’s location.</blockquote><blockquote><strong>File Encoding:</strong> The CSV file’s character encoding. Naturally, it is set to the framework default.</blockquote><blockquote><strong>Variable Names</strong>: a list of variable names separated by commas that will be used to store the CSV file’s data. Every variable name relates to a segment in the CSV document.</blockquote><blockquote><strong>Delimiter</strong>: the character that separated the values in a CSV file with a delimiter. The default setting is “,”</blockquote><blockquote><strong>Allow Quoted Data:</strong> JMeter will allow data values to be enclosed in quotes if this setting is set to true. If your data contains the delimiter character, this is helpful.</blockquote><blockquote><strong>Recycle on EOF:</strong> If this setting is true, when the CSV file reaches its end, JMeter will start over from the beginning. The test will end when it reaches the end of the file if the value is false.</blockquote><blockquote><strong>Stop Thread on EOF</strong>: JMeter will stop the thread when it reaches the end of the CSV file if the value is true.</blockquote><blockquote><strong>Sharing Mode</strong>: The CSV file’s sharing mode. It is set to “All threads” by default, indicating that the same data set will be shared by all threads. By selecting “Current thread,” you can also choose to have each thread use its own data set.</blockquote><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*f6CdheqM7r11v1Fkk0wX1A.png" /></figure><h3>Use JMeter Variable</h3><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WwXbrIRNurSH-BfSBVISTA.png" /></figure><h3><strong>Correlation:</strong></h3><h3>Store Token as variable from /login endpoint request to the server</h3><ol><li>First, use the JMeter HTTP(S) request for your endpoint</li><li>Add a Json Extractor to the HTTP request for the login request.</li><li>Choose a variable name of your choice, such as “token” for Names of created variables</li><li>Enter JSON path Expressions by grabbing the token value from the JSON response body for the endpoint such as $.token</li><li>Add a Beanshell PostProcessor as a child of the HTTP Request sampler.</li></ol><ul><li>In the script area, access the value of the “userID” variable using the following code:</li></ul><pre>props.put(&quot;tokenVariable&quot;, vars.get(&quot;token&quot;));<br><br>or<br><br>vars.put(&quot;manipulatedUserID&quot;, manipulatedUserID);</pre><p>The two distinct objects used to store and retrieve values in JMeter are <strong>props</strong> and <strong>vars</strong>.</p><p><strong>props</strong> represents properties and is a global object that stores JMeter properties. It is accessible from any location in the test plan. The <strong>props.put</strong> method can be used to set a property’s value, and the <strong>props.get </strong>method can be used to get a property’s value. Typically, the jmeter.properties file or the command line are used to define properties.</p><p>On the other hand variables are stored and retrieved for a thread group with the help of <strong>vars</strong>. Each string bunch has its own arrangement of factors. The <strong>vars.put</strong> method can be used to set a variable’s value, and the <strong>vars.get</strong> method can be used to get a variable’s value.</p><p>Therefore, the primary distinction between <strong>props.put</strong> and <strong>vars.pu</strong>t is that <strong>props.put</strong> is global and accessible from any location, whereas <strong>vars</strong> is confined to a particular thread group.</p><p>Example:</p><ul><li>Response body contains token that will be used in other thread groups, We use JSON Path Tester to help us find the JSON Path Expression.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*NgC_95rXJe6KZ53dWoaUWg.png" /></figure><ul><li>ADD in the HTTP request a JSON Extractor.</li><li>under Names of created variables assign your variable name “token”</li><li>under JSON Path expressions: enter the expression “$.token” to extract this value and save it in token variable</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*xywXdLEM5eeXWE6cpJ4nAQ.png" /></figure><ul><li>Add in HTTP request a BeanShell PostProcessor</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*jZl4QkaDkvmU7COXR_phwQ.png" /></figure><h3>Using BeanShell PostProcessor to save the Variable</h3><ul><li>Now we can use <strong>props.put</strong> to store the variable globally so we can re-use it in different Thread groups within this Test Plan.<br>“tokenVariable” is the new variable name assigned so we can use it across test cases. vars.get(“token”) grabs the token that we passed in JSON extractor.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*YHwBLx5ML_P4MwvQXgQDdw.png" /></figure><blockquote>Here is a description of each field in the BeanShell PostProcessor</blockquote><blockquote>If “<strong>reset interpreter</strong>” is set to F<strong>alse</strong> in a BeanShell PostProcessor, it implies that a similar example of the BeanShell translator will be utilized for every cycle of the content. If you need to keep some variables or state between iterations of the script, this can be helpful.</blockquote><blockquote>A new instance of the BeanShell interpreter will be created for each script iteration if “<strong>reset</strong> <strong>interpreter</strong>” is set to <strong>True</strong>. This can be useful if you don’t want variables or state to carry over from one iteration to the next and want the script to start from scratch for each iteration.</blockquote><blockquote><strong>Reset the Interpreter</strong>: Before running the script, this checkbox is used to reset the BeanShell interpreter. If checked, each time the script is run, a new BeanShell interpreter will be created. It will use the existing interpreter if the box is unchecked.</blockquote><blockquote><strong>Parameters</strong>: The parameters that the script will receive are specified in this field. Using a comma, you can separate multiple parameters.</blockquote><blockquote><strong>Filename</strong>: The filename of the script that will be run can be entered in this field. Only the script’s name needs to be specified if it is in the same folder as the test plan. Otherwise, the script’s full path must be specified.</blockquote><blockquote><strong>Script</strong>: The actual BeanShell script is created with the help of this field. The logic that will be carried out must be included in the BeanShell scripting language. The following items are accessible to the script: ctx, log, props, and vars</blockquote><h3>Option 2 using BeanShell Assertion instead of BeanShell PostProcessor</h3><pre>${__setProperty(tokenVariable,${token})}</pre><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*Cmgrftm6hzD0PaqqkMHBQA.png" /></figure><h3>Using the Variable</h3><ul><li>To access we use <strong>${__property(tokenVariable)}</strong> for this instance Its under HTTP Header Manager so it can be call for each Thread Group</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*-p9renagQsmp9DLUhbHdNg.png" /></figure><blockquote><strong>Lets keep learning how to use Variables</strong></blockquote><p><strong>User Defined Variables</strong>: At the test plan level, you can define variables and their values with this element. The test plan can make use of these variables throughout.</p><p>Open JMeter and create a new Test Plan.</p><p>Right-click on the Test Plan and select Add &gt; Config Element &gt; User Defined Variables.</p><p>In the Name column, add the name of the variable you want to define, and in the Value column, add the value for that variable. For example, you can add:</p><ul><li>Name: BASE_URL<br>Value: api.octoperf.com</li><li>Name: USERNAME<br>Value: demo@gmail.com</li><li>Name: PASSWORD<br>Value: testdat12</li></ul><p>Once you have added all the variables you need, click on the OK button to save the changes.</p><p>To use these variables in your requests, you can simply reference them by their name enclosed in ${} curly braces. For example, if you want to use the BASE_URL variable in a HTTP Request, you can set the Server Name or IP field to ${BASE_URL}.</p><p>Example:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*0uqhRi9mBwLKGREaNmoQKQ.png" /></figure><ul><li>Create a User Defined Variables in the Thread Group and enter your Key and Value as shown below.</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*5NHPqWzhR1EWWrfHHjNE-Q.png" /></figure><ul><li>Now Use that Variable you create by using ${}</li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*UpZ_yc8EFM29ETIhNwOPhw.png" /></figure><p><em>In conclusion, variables are an essential part of JMeter test plans as they help to simplify the test creation process and increase reusability. Understanding how to use variables correctly can greatly improve the efficiency and effectiveness of your performance testing. If you have any further questions or need more in-depth information, </em><strong><em>feel free to follow up with me for more content in JMeter.</em></strong></p><p><em>#JMeterVariables #JMeterParameterization #PerformanceTesting #LoadTesting #TestAutomation #SoftwareTesting #DevOps #QualityAssurance #APItesting #WebTesting</em></p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=60c4b0d52bb0" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[ChatGPT and Postman API Testing]]></title>
            <link>https://medium.com/@alex_rodriguez_soto/chatgpt-and-postman-api-testing-c275165ccc76?source=rss-87c96085ecee------2</link>
            <guid isPermaLink="false">https://medium.com/p/c275165ccc76</guid>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[postman]]></category>
            <category><![CDATA[ai]]></category>
            <category><![CDATA[chatgpt]]></category>
            <category><![CDATA[api]]></category>
            <dc:creator><![CDATA[Alex Rodriguez]]></dc:creator>
            <pubDate>Fri, 03 Mar 2023 05:13:49 GMT</pubDate>
            <atom:updated>2023-03-03T05:13:49.943Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/850/1*SRtY3_N04CZ_z1bB1uTYYA.png" /></figure><p>OpenAI’s ChatGPT is a powerful language model that can use prompts to generate text in natural language. We can automate the process of creating Postman test scripts by making use of ChatGPT’s capabilities.</p><p>For API testing, creating test scripts in Postman is essential because it enables you to automate the process, improve productivity, and lessen the likelihood of human error. Additionally, it enables you to quickly and repeatedly conduct tests, allowing you to identify issues before they escalate into major issues.</p><p>Let us get started:</p><ul><li><strong>Verify the status code is valid when testing your API endpoints.</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/794/1*WqtwQLVKnd0weiVvF1iPTQ.png" /></figure><p>Let us see it in action using Postman Test scripts:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*zW3R46UlQ5Vm5nK7ulW9RA.png" /></figure><p>Try it yourself:</p><pre>try {<br>  pm.test(&quot;Status code is 200&quot;, function () {<br>    pm.response.to.have.status(200);<br>  });<br>} catch (err) {<br>  console.log(err);<br>  pm.test(&quot;Status code is not 200&quot;, function () {<br>    pm.expect.fail(&quot;Status code is not 200&quot;);<br>  });<br>}</pre><p>The pm.test function is used to create a test in this script to examine the response’s status code. The status code is verified by the pm.response.to.have.status(200) function to be 200.</p><p>A try-catch block is also being used to deal with any errors that might occur while the test is being run. The catch block will define a new test that fails with a custom message if an error occurs and log the error to the console. This makes sure that the test results are easy to understand and use.</p><ul><li><strong>Verify Environment:</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/788/1*FYbv3GiBcXqT9PfxJVt-_g.png" /></figure><p>Let us see it in action using Postman Test scripts:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/990/1*VSfYfCdYzar-kCsekb-sqQ.png" /></figure><p>Try it yourself:</p><pre>pm.test(&quot;Current environment is production&quot;, function () {<br>    pm.expect(pm.environment.name).to.eql(&quot;production&quot;);<br>});</pre><p>The current environment name is compared to “<strong>production</strong>” by this test script. The test will fail if the environment name is not “production.”</p><p>Change the string value in the <strong>pm.expect()</strong> statement to check for a different environment name in the test script.</p><ul><li><strong>Validate Response Body include try catch to verify if the response is other than Json</strong></li></ul><figure><img alt="" src="https://cdn-images-1.medium.com/max/783/1*vnV8wQPj12fZc2reYoCQCA.jpeg" /></figure><p>Let us see it in action using Postman Test scripts:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/980/1*AeL9uXcmVnYn-d8_PeX_zw.jpeg" /></figure><p>Try it yourself:</p><pre>try { // you can add validation for status code if you desire<br>  pm.expect(pm.response.code).to.be.oneOf([200, 201, 202]); // Validate response code<br>  <br>  var jsonData = pm.response.json(); // Parse response body to JSON<br>  <br>  pm.test(&#39;Response body is not empty&#39;, function() {<br>    pm.expect(jsonData).to.not.be.null;<br>    pm.expect(jsonData).to.not.be.undefined;<br>  });<br>  <br>  pm.test(&#39;Response body contains expected values&#39;, function() {<br>    pm.expect(jsonData.property1).to.eql(&#39;expectedValue1&#39;);<br>    pm.expect(jsonData.property2).to.eql(&#39;expectedValue2&#39;);<br>    // Add more validations as needed<br>  });<br>  <br>} catch (err) {<br>  console.error(err);<br>  pm.test(&#39;Test failed&#39;, function() {<br>    pm.expect.fail(err);<br>  });<br>}</pre><p>The <strong>pm.response.json()</strong> function is used to convert the response body into JSON, and the pm.test function is used to add two test cases. The first test case ensures that the response body is not empty, while the second test case ensures that the response body contains the expected values for properties 1 and 2. As needed, you can add additional validations.</p><p>Finally, to deal with any errors that may arise during the script’s execution, we wrap the entire script in a try-catch block. We use the pm.expect.fail function to fail the test and log any errors to the console.</p><p>In conclusion, developing test scripts for the Postman API can be greatly streamlined and time-saving when carried out with ChatGPT. ChatGPT is able to generate code for test scenarios thanks to its ability to comprehend inputs written in natural language.</p><blockquote>Note: As noted, this documentation is only to show that you can generate test scripts, but you need to make sure if they apply to your use case. You can write many more test scripts such as the ones shown in these scenarios. This is just an example of combining ChatGPT with Postman to write Postman test scripts.</blockquote><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=c275165ccc76" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Variables and data types — Java]]></title>
            <link>https://medium.com/@alex_rodriguez_soto/variables-and-data-types-b9ec820a6405?source=rss-87c96085ecee------2</link>
            <guid isPermaLink="false">https://medium.com/p/b9ec820a6405</guid>
            <category><![CDATA[programming]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[development]]></category>
            <category><![CDATA[coding]]></category>
            <dc:creator><![CDATA[Alex Rodriguez]]></dc:creator>
            <pubDate>Sun, 26 Feb 2023 06:21:32 GMT</pubDate>
            <atom:updated>2023-02-26T06:50:28.733Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/0*LS7NzwKYx7BXSj48.jpg" /><figcaption>A marble-filled jar could represent a variable that stores an integer value</figcaption></figure><p>In programming, data types are used to specify the kind of data a variable or function can return. Data types vary by programming language, but some common examples include:</p><ol><li>Integer: Used to store whole numbers (e.g., 1, 2, 3, etc.)</li><li>Floating-point: Used to store decimal numbers (e.g., 1.5, 3.14, etc.)</li><li>Boolean: Used to store true or false values (e.g., true, false)</li><li>Character: Used to store a single character (e.g., ‘a’, ‘b’, ‘c’, etc.)</li><li>String: Used to store a sequence of characters (e.g., “hello world”)</li></ol><p>Because they determine the size of a variable in memory and the operations that can be carried out on it, data types are crucial. For instance, adding two integer values will produce an integer, whereas adding two integer values will produce a floating-point value.</p><p>Numerous programming languages support more complex data types like arrays, structures, and classes in addition to these basic data types. Programmers can more easily manipulate related data by grouping them into these data types.</p><p>Values that can be manipulated and used throughout a program are stored in variables. A variable must be declared with a particular data type before it can be used. This type of data type specifies the kind of value the variable can hold. The following are some Java data types and examples of how to use them:</p><ul><li>int: used to store integer values</li></ul><pre>int x = 5;<br>int y = 10;<br>int sum = x + y;jab</pre><ul><li>double: used to store decimal values</li></ul><pre>double price = 19.99;<br>double taxRate = 0.08;<br>double total = price * (1 + taxRate);</pre><ul><li>String: used to store text values</li></ul><pre>String name = &quot;John&quot;;<br>String message = &quot;Hello, &quot; + name + &quot;!&quot;;<br>System.out.println(message);</pre><ul><li>boolean: used to store true/false values</li></ul><pre>boolean isRaining = true;<br>boolean isSunny = false;<br>if (isRaining) {<br>    System.out.println(&quot;Bring an umbrella.&quot;);<br>}</pre><ul><li>char: used to store a single character value</li></ul><pre>char firstLetter = &#39;J&#39;;<br>char lastLetter = &#39;D&#39;;<br>String initials = firstLetter + &quot;.&quot; + lastLetter + &quot;.&quot;;</pre><ul><li>byte: used to store small integer values (-128 to 127)</li></ul><pre>byte age = 25;<br>byte numStudents = 30;<br>byte total = (byte) (age + numStudents);</pre><ul><li>short: used to store small integer values (-32,768 to 32,767)</li></ul><pre>short num1 = 1000;<br>short num2 = 2000;<br>short sum = (short) (num1 + num2);</pre><ul><li>long: used to store large integer values (-9,223,372,036,854,775,808 to 9,223,372,036,854,775,807)</li></ul><pre>long population = 7_500_000_000L;<br>long debt = 23_000_000_000_000L;<br>long debtPerPerson = debt / population;</pre><ul><li>float: used to store decimal values with less precision than double</li></ul><pre>float price = 19.99f;<br>float taxRate = 0.08f;<br>float total = price * (1 + taxRate);</pre><ul><li>double arrays: used to store a collection of decimal values</li></ul><pre>double[] temperatures = { 68.3, 72.1, 70.9, 69.2 };<br>double average = 0;<br>for (double temp : temperatures) {<br>    average += temp;<br>}<br>average /= temperatures.length;</pre><p>Programming relies heavily on variables because they enable dynamic data storage and manipulation during program execution. We can give a variable a specific meaning or use it to represent a particular idea or calculation by assigning it a value.</p><p>If we wanted to determine the area of a rectangle, for instance, we could declare two variables to represent its length and width and then use a formula to determine its area:</p><pre>int length = 5;<br>int width = 10;<br>int area = length * width;<br>System.out.println(&quot;The area of the rectangle is: &quot; + area);</pre><p>Every time we wanted to calculate the area of a rectangle, we would have to hardcode the values into the formula without variables, which would be time-consuming and prone to error. We can write code that can handle a variety of inputs and situations and is more adaptable and reusable by using variables.</p><p>Variables also give us the ability to store and change data throughout the program, which is crucial when working with intricate algorithms or data structures. We can keep track of intermediate results and make decisions based on the program’s current state by updating a variable’s value at various points.</p><p>In general, variables are a fundamental programming concept that enable us to write code that is more effective, adaptable, and easy to maintain while also enabling us to work dynamically with data.</p><p>There are a number of advantages to programming with data types:</p><p><strong>Type safety</strong>: The compiler can check that the data being used is of the correct type by specifying the data type of a variable. This can help prevent errors and increase code reliability.</p><p><strong>Memory capacity</strong>: When working with large datasets or running code on systems with limited resources, choosing the right data type can help reduce the amount of memory required to store a value.</p><p><strong>Improved performance</strong>: Programmers can write code that runs faster and more efficiently by using data types that are optimized for particular operations, like integer arithmetic or floating-point calculations.</p><p><strong>Readability of code</strong>: Code can be made easier to understand and maintain over time by using descriptive data types like “firstName” or “age,” which can help reduce the likelihood of errors and bugs.</p><p><strong>Maintenance ease</strong>: Programmers can easily see what data is being used where when data types are used consistently throughout a program. This makes it easier to update and modify the code over time.</p><p>In general, using data types is an important part of programming that can help make code better, work better, and be easier to maintain. Programmers can produce code that is more readable, efficient, and reliable by comprehending the advantages of various data types and making appropriate use of them.</p><p>Thank you for reading! Please follow me for more helpful content.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=b9ec820a6405" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Postman Test Scripts parte 2]]></title>
            <link>https://medium.com/@alex_rodriguez_soto/postman-test-scripts-parte-2-7a09148905fa?source=rss-87c96085ecee------2</link>
            <guid isPermaLink="false">https://medium.com/p/7a09148905fa</guid>
            <category><![CDATA[api]]></category>
            <category><![CDATA[postman]]></category>
            <category><![CDATA[automation]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[development]]></category>
            <dc:creator><![CDATA[Alex Rodriguez]]></dc:creator>
            <pubDate>Sun, 26 Feb 2023 04:46:35 GMT</pubDate>
            <atom:updated>2023-02-26T04:46:35.779Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*uaqtxzJajHCDHmBJP-W0yg.png" /></figure><p>Script de prueba avanzada del Postman: mejores métodos y técnicas</p><p>Puede automatizar las pruebas y crear conjuntos de pruebas con Postman, una popular herramienta de prueba API. Examinaremos ejemplos avanzados de guiones de prueba de Postman y estrategias efectivas de uso de guiones en esta publicación de blog.</p><p>Introducción:<br>Es esencial emplear métodos de vanguardia y mejores prácticas de la industria para garantizar la escalabilidad y confiabilidad de sus pruebas API. En esta publicación de blog se analizarán ejemplos avanzados de script de prueba de Postman, incluidos métodos para probar API con datos dinámicos, usar variables y funciones para datos de prueba y escribir pruebas basadas en datos. Los scripts de prueba de Postman que son escalables y fáciles de mantener también serán el tema de nuestra discusión.</p><p>Guiones para pruebas avanzadas de Postman:</p><p>Uso de datos dinámicos para probar API:<br>Para funcionar correctamente, las API con frecuencia requieren tokens de autenticación u otros datos dinámicos. Automatizaremos el proceso de obtención de un token JWT y pasarlo a solicitudes posteriores en este ejemplo haciendo uso de las capacidades de secuencias de comandos proporcionadas por Postman.</p><p>Prueba de utilización de datos utilizando funciones y variables:<br>Administrar los datos de manera efectiva con variables y funciones es fundamental cuando se prueban las API con muchos datos. Le mostraremos cómo usar variables y funciones para crear datos de prueba para una API complicada en este ejemplo.</p><p>Pruebas basadas en datos utilizando Collection Runner:<br>Usando un archivo CSV como datos de entrada, puede ejecutar una serie de pruebas con Postman’s Collection Runner. Usando un archivo CSV como entrada, usaremos el Administrador de colecciones para realizar una serie de pruebas en una API de muestra en este ejemplo.</p><p>Uso de la Biblioteca de Afirmación de Chai para Pruebas de Escritura:<br>Puede usar la biblioteca de aserciones Chai en Postman para escribir pruebas que sean más potentes y expresivas. Le mostraremos cómo usar Chai para escribir pruebas que busquen propiedades específicas en la respuesta API en este ejemplo.</p><p>Ejemplos:</p><p>1). Uso de datos dinámicos para probar API:<br>Utilizando las capacidades de secuencias de comandos de Postman, puede automatizar el proceso de obtención de un token y pasarlo a solicitudes posteriores al probar API que requieren tokens de autenticación. Aquí se proporciona un script de ejemplo que almacena un token JWT en una variable y lo recupera de una API:</p><pre>pm.sendRequest({<br>    url: &#39;https://example.com/api/auth&#39;,<br>    method: &#39;POST&#39;,<br>    header: { &#39;Content-Type&#39;: &#39;application/json&#39; },<br>    body: {<br>        mode: &#39;raw&#39;,<br>        raw: JSON.stringify({<br>            username: &#39;user&#39;,<br>            password: &#39;password&#39;<br>        })<br>    }<br>}, function(err, res) {<br>    pm.environment.set(&#39;jwtToken&#39;, res.json().token);<br>});</pre><p>Con un nombre de usuario y contraseña incluidos en el cuerpo de la solicitud, este script envía una solicitud POST a un punto final de autenticación. Almacena el token JWT en una variable de entorno llamada jwtToken si la autenticación es exitosa. El token JWT se recupera de la respuesta API. Después de eso, puede consultar esta variable como “ jwtToken ” en solicitudes posteriores.</p><p>2). Prueba de utilización de datos utilizando funciones y variables:<br>Puede generar datos dinámicamente utilizando variables y funciones para administrar grandes cantidades de datos de prueba. Aquí se proporciona una ilustración de un script que utiliza una dirección de correo electrónico aleatoria en un cuerpo de solicitud:</p><pre>function generateEmail() {<br>    var chars = &#39;abcdefghijklmnopqrstuvwxyz1234567890&#39;;<br>    var email = &#39;&#39;;<br>    for (var i = 0; i &lt; 10; i++) {<br>        email += chars[Math.floor(Math.random() * chars.length)];<br>    }<br>    email += &#39;@example.com&#39;;<br>    return email;<br>}<br><br>var email = generateEmail();<br><br>pm.sendRequest({<br>    url: &#39;https://example.com/api/users&#39;,<br>    method: &#39;POST&#39;,<br>    header: { &#39;Content-Type&#39;: &#39;application/json&#39; },<br>    body: {<br>        mode: &#39;raw&#39;,<br>        raw: JSON.stringify({<br>            name: &#39;John Doe&#39;,<br>            email: email<br>        })<br>    }<br>});</pre><p>Una función llamada generaEmail se define en este script. Crea una dirección de correo electrónico aleatoria y la almacena en una variable llamada correo electrónico. La dirección de correo electrónico está incluida en el cuerpo de la solicitud POST que el script envía a un punto final API.</p><p>3). Pruebas basadas en datos utilizando Collection Runner:<br>Postman’s Collection Runner se puede usar para ejecutar una serie de pruebas con datos de un archivo CSV. Puede encontrar un archivo CSV de muestra que contenga datos de prueba aquí:</p><pre>Example of a CSV format file comma separated<br><br>name,email<br>John Doe,john@example.com<br>Jane Smith,jane@example.com</pre><p>El archivo CSV se puede usar como datos de entrada para una serie de pruebas API que se pueden ejecutar con Collection Runner. Aquí se proporciona una ilustración de un script que usa el nombre y el correo electrónico del archivo CSV en un cuerpo de solicitud:</p><pre>pm.sendRequest({<br>    url: &#39;https://example.com/api/users&#39;,<br>    method: &#39;POST&#39;,<br>    header: { &#39;Content-Type&#39;: &#39;application/json&#39; },<br>    body: {<br>        mode: &#39;raw&#39;,<br>        raw: JSON.stringify({<br>            name: pm.iterationData.name,<br>            email: pm.iterationData.email<br>        })<br>    }<br>});</pre><p>El nombre y los valores de correo electrónico del archivo CSV se recuperan y asignan al cuerpo de solicitud mediante este script, que utiliza el objeto pm.iterationData.</p><p>4). Escribir pruebas con Chai Assertion Library: para escribir pruebas más expresivas, puede usar la biblioteca de aserciones Chai. Aquí hay un script de ejemplo que verifica si una respuesta JSON contiene una propiedad específica:</p><pre>pm.test(&quot;Response contains user id&quot;, function() {<br>    var jsonData = pm.response.json();<br>    pm.expect(responseData.id).to.equal(&#39;expected ID Value&#39;);<br>});</pre><p>5). Evaluación de desempeño con Newman:<br>Newman, la herramienta de línea de comandos para ejecutar colecciones desarrollada por Postman, se puede utilizar para examinar el rendimiento de una API bajo carga. Un script de ejemplo para ejecutar una prueba de carga en una API usando Newman es el siguiente:</p><pre>newman run mycollection.json -n 1000</pre><p>Este script simula una carga de 1000 usuarios concurrentes ejecutando la colección mycollection.json 1000 veces. Puede examinar el rendimiento de la API bajo carga observando los códigos de estado y los tiempos de respuesta que Newman realiza un seguimiento de cada solicitud.</p><p>6). Uso de archivos de datos para probar una variedad de puntos finales:<br>Puede probar múltiples puntos finales con diferentes datos de entrada haciendo uso de la función de archivos de datos de Postman. Aquí se proporciona un script de ejemplo que prueba múltiples puntos finales API y lee los datos de entrada de un archivo CSV:</p><pre>const csv = require(&#39;csvtojson&#39;);<br><br>csv()<br>  .fromFile(&#39;input.csv&#39;)<br>  .then((data) =&gt; {<br>    data.forEach((item) =&gt; {<br>      pm.sendRequest({<br>        url: `https://api.example.com/users/${item.id}`,<br>        method: &#39;PUT&#39;,<br>        body: {<br>          name: item.name,<br>          email: item.email<br>        }<br>      }, function (err, res) {<br>        pm.test(`Update user ${item.id} succeeds`, function () {<br>          pm.expect(res.status).to.equal(200);<br>          pm.expect(res.json().success).to.equal(true);<br>        });<br>      });<br>    });<br>  });</pre><p>Uso de tokens OAuth2 para probar la autenticación:<br>Puede probar los flujos de autenticación con el soporte incorporado de Postman para tokens OAuth2 si su API requiere autenticación. Aquí se proporciona una ilustración de un script que obtiene un token OAuth2 y lo usa para verificar solicitudes posteriores:</p><pre>pm.sendRequest({<br>  url: &#39;https://auth.example.com/oauth2/token&#39;,<br>  method: &#39;POST&#39;,<br>  header: {<br>    &#39;Content-Type&#39;: &#39;application/x-www-form-urlencoded&#39;<br>  },<br>  body: {<br>    mode: &#39;urlencoded&#39;,<br>    urlencoded: [<br>      { key: &#39;grant_type&#39;, value: &#39;client_credentials&#39; },<br>      { key: &#39;client_id&#39;, value: &#39;your_client_id&#39; },<br>      { key: &#39;client_secret&#39;, value: &#39;your_client_secret&#39; }<br>    ]<br>  }<br>}, function (err, res) {<br>  pm.environment.set(&#39;access_token&#39;, res.json().access_token);<br>});<br><br>pm.sendRequest({<br>  url: &#39;https://api.example.com/users&#39;,<br>  method: &#39;GET&#39;,<br>  header: {<br>    &#39;Authorization&#39;: `Bearer ${pm.environment.get(&#39;access_token&#39;)}`<br>  }<br>}, function (err, res) {<br>  pm.test(&quot;Response status code is 200&quot;, function() {<br>    pm.expect(res.status).to.equal(200);<br>  });<br>});</pre><p>Al proporcionar credenciales del cliente en una solicitud POST a un servidor de autorización, este script obtiene un token OAuth2. El token se guarda en una variable de entorno y se usa para autenticar solicitudes de punto final API posteriores. Para garantizar que la solicitud haya sido exitosa, el script verifica el código de estado de la respuesta.</p><p>7). Examinando la paginación:<br>Puede probar la paginación con Postman si su API devuelve muchos resultados paginados. Un script de ejemplo que envía una solicitud GET a un punto final de API, devuelve resultados paginados y verifica que el número total de resultados devueltos coincida con el número esperado que se proporciona aquí:</p><pre>pm.sendRequest({<br>  url: &#39;https://api.example.com/users?page=1&#39;,<br>  method: &#39;GET&#39;<br>}, function (err, res) {<br>  pm.test(&quot;Response status code is 200&quot;, function() {<br>    pm.expect(res.status).to.equal(200);<br>  });<br><br>  pm.test(&quot;Total number of results is correct&quot;, function() {<br>    pm.expect(res.json().total_count).to.equal(100);<br>  });<br><br>  const totalPages = Math.ceil(res.json().total_count / 10);<br><br>  for (let page = 2; page &lt;= totalPages; page++) {<br>    pm.sendRequest({<br>      url: `https://api.example.com/users?page=${page}`,<br>      method: &#39;GET&#39;<br>    }, function (err, res) {<br>      pm.test(`Response status code for page ${page} is 200`, function() {<br>        pm.expect(res.status).to.equal(200);<br>      });<br>    });<br>  }<br>});</pre><p>Este script envía una solicitud GET a la primera página de un punto final de API paginado y verifica que el número total de resultados es el mismo que se esperaba ( 100 en este caso ) y que El código de estado de respuesta es 200. Luego envía solicitudes GET posteriores a cada página para probar el código de estado de respuesta para cada página, calcular el número total de páginas en función del número de resultados por página ( 10 en este ejemplo ).</p><pre>for (let i = 1; i &lt;= 11; i++) {<br>  pm.sendRequest({<br>    url: &#39;https://api.example.com/users/123&#39;,<br>    method: &#39;GET&#39;<br>  }, function (err, res) {<br>    if (i &lt; 11) {<br>      pm.test(`Response status code for request ${i} is 200`, function() {<br>        pm.expect(res.status).to.equal(200);<br>      });<br>    } else {<br>      pm.test(&quot;Response status code for request 11 is 429&quot;, function() {<br>        pm.expect(res.status).to.equal(429);<br>      });<br>    }<br>  });<br><br>  pm.wait(1000);<br>}</pre><p>Con un segundo entre cada solicitud, este script envía 11 solicitudes GET a un punto final de API. Dado que la API limita el número de solicitudes realizadas por minuto a diez, la undécima solicitud debe dar como resultado el código de estado 429 Demasiadas solicitudes. El script verifica si el código de estado de respuesta para las primeras diez solicitudes es 200 y si es 429 para la undécima solicitud.</p><p>8). Probar las API GraphQL:<br>Postman se puede usar para probar consultas y mutaciones de GraphQL si su API usa GraphQL. Aquí se proporciona un script de ejemplo que prueba la respuesta de una consulta GraphQL enviada a un punto final API:</p><pre>pm.sendRequest({<br>  url: &#39;https://api.example.com/graphql&#39;,<br>  method: &#39;POST&#39;,<br>  header: {<br>    &#39;Content-Type&#39;: &#39;application/json&#39;<br>  },<br>  body: {<br>    mode: &#39;graphql&#39;,<br>    graphql: {<br>      query: `<br>        query ($id: ID!) {<br>          user(id: $id) {<br>            id<br>            name<br>            email<br>          }<br>        }<br>      `,<br>      variables: {<br>        id: &#39;123&#39;<br>      }<br>    }</pre><p>GraphQL API Postman script example:</p><pre>// Set the GraphQL query and variables<br>const query = `<br>  query GetUser($id: ID!) {<br>    user(id: $id) {<br>      id<br>      name<br>      email<br>    }<br>  }<br>`;<br>const variables = {<br>  id: 1<br>};<br><br>// Send the GraphQL request<br>pm.sendRequest({<br>  url: &#39;https://my-graphql-api.com/graphql&#39;,<br>  method: &#39;POST&#39;,<br>  header: {<br>    &#39;Content-Type&#39;: &#39;application/json&#39;,<br>  },<br>  body: {<br>    mode: &#39;raw&#39;,<br>    raw: JSON.stringify({<br>      query,<br>      variables,<br>    }),<br>  },<br>}, (err, response) =&gt; {<br>  // Validate the response<br>  pm.test(&#39;Response is valid&#39;, () =&gt; {<br>    pm.expect(response).to.have.status(200);<br>    pm.expect(response.json()).to.have.property(&#39;data&#39;);<br>    pm.expect(response.json().data).to.have.property(&#39;user&#39;);<br>    pm.expect(response.json().data.user).to.have.property(&#39;id&#39;, 1);<br>    pm.expect(response.json().data.user).to.have.property(&#39;name&#39;, &#39;John Doe&#39;);<br>    pm.expect(response.json().data.user).to.have.property(&#39;email&#39;, &#39;john.doe@example.com&#39;);<br>  });<br><br>  // Save the access token for future requests<br>  const accessToken = response.json().data.accessToken;<br>  pm.environment.set(&#39;access_token&#39;, accessToken);<br>});</pre><p>Las variables de consulta y solicitud de GraphQL se establecen primero en este script. La solicitud se envía a la API a través de la función pm.sendRequest con un encabezado de tipo de contenido de aplicación / json y el método POST. La consulta y las variables se representan como una cadena JSON en la propiedad del cuerpo.</p><p>Utilizamos pm.test para verificar la respuesta después de que se haya enviado la solicitud. Nos aseguramos de que la respuesta tenga un código de estado de 200, una propiedad de datos y una propiedad de usuario con la ID, nombre y correo electrónico esperados en la propiedad de datos.</p><p>En conclusión, la propiedad accessToken de la respuesta se guarda en el entorno de Postman para que pueda utilizarse en solicitudes posteriores. Utilizamos la función pm.environment.set para establecer la variable de entorno access_token en el valor de la propiedad accessToken para lograr esto.</p><p>Hemos discutido una serie de scripts avanzados de Postman en este artículo, como los de validar códigos y organismos de estado de respuesta, manejar errores con bloques de prueba, y guardar tokens de autenticación para solicitudes posteriores.</p><p>Gracias por leer! Siga para obtener más contenido útil.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=7a09148905fa" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>