<?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 Pavithradevi C on Medium]]></title>
        <description><![CDATA[Stories by Pavithradevi C on Medium]]></description>
        <link>https://medium.com/@pavithradevi.c?source=rss-42b699077c17------2</link>
        <image>
            <url>https://cdn-images-1.medium.com/fit/c/150/150/1*dmbNkD5D-u45r44go_cf0g.png</url>
            <title>Stories by Pavithradevi C on Medium</title>
            <link>https://medium.com/@pavithradevi.c?source=rss-42b699077c17------2</link>
        </image>
        <generator>Medium</generator>
        <lastBuildDate>Mon, 30 Nov 2026 03:28:27 GMT</lastBuildDate>
        <atom:link href="https://medium.com/@pavithradevi.c/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[Database Performance Testing using JMeter tool]]></title>
            <link>https://medium.com/@pavithradevi.c/database-performance-testing-using-jmeter-tool-eaa4b3df60ae?source=rss-42b699077c17------2</link>
            <guid isPermaLink="false">https://medium.com/p/eaa4b3df60ae</guid>
            <category><![CDATA[sql-server]]></category>
            <category><![CDATA[performance-testing]]></category>
            <category><![CDATA[database]]></category>
            <category><![CDATA[jmeter]]></category>
            <category><![CDATA[jdbc-driver]]></category>
            <dc:creator><![CDATA[Pavithradevi C]]></dc:creator>
            <pubDate>Mon, 25 Mar 2024 07:34:47 GMT</pubDate>
            <atom:updated>2024-03-25T07:34:47.663Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/497/1*FsrDX2TrV-bBkm4UnNdUug.png" /></figure><p>In this article, I would like to share how to perform Database performance testing using the JMeter tool.</p><p><strong>why database performance testing is crucial?</strong></p><p>Database performance testing is really important because it helps make sure that databases work well and fast. It checks if the database can handle lots of users and data without getting slow or crashing. This testing helps find any problems, like if the database uses too much of the computer’s resources or if it’s not responding quickly. By fixing these issues, developers make sure that the database works smoothly, which means happier users and lower costs for running the database.</p><p><strong>Overview of JMeter: A tool for performance testing:</strong></p><p>Apache JMeter is a widely used open-source tool for performance testing, mainly for web applications. It simulates heavy loads on servers to test their performance under different conditions, helping identify bottlenecks. It supports various protocols, has a user-friendly GUI for creating test plans, and offers flexible scripting options for advanced users. JMeter’s assertions feature allows testers to verify the correctness of server responses. Overall, it’s a versatile tool for ensuring the reliability and scalability of software systems.</p><p><strong>Database Performance testing</strong></p><p>Before diving into the procedural steps, it is essential to confirm the presence of the following prerequisites:</p><p>Database: Choose a database that suits the needs of your project.</p><p>Database Credentials: Verify that you possess the credentials to access the selected database.</p><p>JMeter Installation: Confirm the successful installation of JMeter on your machine.</p><p><strong>Step 1: Launch JMeter</strong></p><p>You can run JMeter using the “jmeter.bat” file in the “bin” folder. Here is a screenshot of JMeter GUI:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*4TQA8bLsH8c0tf8sA0LOBg.png" /></figure><p><strong>Step 2: Add Thread group to your Test Plan</strong></p><p>Right-click on the Test plan &gt; Click Add &gt; Click Threads &gt; Select Thread Group</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*ikHEeQfNRuRcKI-scZlwxA.png" /></figure><p><strong>Step 3: Setup Thread Group</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*IRCRjHgRS84Ig8BkDsbMSA.png" /></figure><p>Specify essential fields in the Thread group for performance testing:</p><p><strong>Number of Threads</strong>: Specifies the threads used in the load test.</p><p><strong>Ramp-Up Period</strong>: Sets the time to activate all threads. With 10 threads and a 30s ramp-up, one thread starts every 3s, reaching 10 threads in 30s.</p><p><strong>Loop Count</strong>: Determines test executions. Choosing Infinite means the test runs until manually stopped.</p><p><strong>Step 4: Install JDBC driver server</strong></p><p>Download the JDBC driver and install it in the Jmeter “lib” folder.</p><p>Link: <a href="https://learn.microsoft.com/en-us/sql/connect/jdbc/download-microsoft-jdbc-driver-for-sql-server?view=sql-server-ver16">https://learn.microsoft.com/en-us/sql/connect/jdbc/download-microsoft-jdbc-driver-for-sql-server?view=sql-server-ver16</a></p><p>Go to Thread group, Browser the JDBC driver file and add it to the “Add directory or jar to classpath”</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*MVruxqC_BYe1wqXtU0wZYg.png" /></figure><p><strong>Step 5: Add JDBC Config Element for Jmeter</strong></p><p>Right-click on Test plan &gt; Add &gt; Config Elements &gt; JDBC Connection Configuration</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WpJdnxym_Ab6QE6nEBDHdQ.png" /></figure><p>Prepare the Database Connection Configuration as follows:</p><p>Variable name for created pool: give any name</p><p>Database URL: jdbc:sqlserver://<strong>ServerName</strong>;DatabaseName=<strong>your databasename</strong>;encrypt=true;trustServerCertificate=true</p><p>JDBC Driver Class: Select the appropriate driver class from the dropdown menu corresponding to your Database.</p><p>Username and Password: Enter valid credentials for your database.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*8JNdL_UQKIOyrXlzXlbjmA.png" /></figure><p><strong>Step 6: Create JDBC Request</strong></p><p>Right-click on Test plan &gt; Add-&gt;Sampler-&gt;JDBC Request</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*WILArRj_hcowuke8mey_Sw.png" /></figure><p>Enter the Variable name created in the JDBC connection configuration to establish a connection between the configuration and the request.</p><p>Select the Query type from the dropdown and write the SQL Query.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*mnjGipjFTZWi-iV2dWJ7pg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*g84ikK9hT9gbtPYfkPVTaw.png" /></figure><p><strong>Step 7: Add Listeners</strong></p><p>Right-click on Test plan &gt; Add &gt; listener</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*n_8uN87Pyj64rKRjf1vfGw.png" /></figure><p>View Results Tree: Shows detailed information of sampler requests in a tree format for debugging.</p><p>View Results in Table: Displays detailed results of sampler requests in a tabular format.</p><p>Summary Report: Provides an overview of test results including key metrics like average response time and error rate.</p><p>Assertion Results: Indicates whether sampler responses meet specified criteria, helping to verify the correctness of server responses.</p><p><strong>Step 8: Running the test</strong></p><p>Click the Play button at the top to execute the JDBC request and view the result via added listeners.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/902/1*REAm6AxL8reFP-EiPnemCg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*H_rxg2SEDAGXaWraD6x8sQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*DV6oSPeeqTz96KmwIRNg0A.png" /></figure><p><strong>Step 9: Update the user count</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/1024/1*bXalf_3-f0rFqFW-4lQx7A.png" /></figure><p>Go to Thread Group and locate the field or parameter where you specify the number of users (often labeled as “Number of Threads” or “Users”).</p><p>Modify User Count: Change the value in the field to the desired number of users you want to simulate.</p><p>Save Changes: Save your test plan to retain the modifications.</p><p>Run Test: Execute your test plan to simulate the new number of users and observe the results.</p><p><strong>Conclusion:</strong></p><p>Preparing for database performance testing is crucial to ensure the smooth functioning of applications reliant on the database. By setting up the testing environment and comprehending the database structure and queries it handles, we can proactively identify and resolve any issues before they affect users. Through proper preparation, we can guarantee that our applications operate seamlessly, resulting in satisfied users and successful outcomes.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=eaa4b3df60ae" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[SELENIUM vs CYPRESS]]></title>
            <link>https://medium.com/@pavithradevi.c/selenium-vs-cypress-3890017ad6c?source=rss-42b699077c17------2</link>
            <guid isPermaLink="false">https://medium.com/p/3890017ad6c</guid>
            <category><![CDATA[framework]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[selenium]]></category>
            <category><![CDATA[java]]></category>
            <category><![CDATA[cypress]]></category>
            <dc:creator><![CDATA[Pavithradevi C]]></dc:creator>
            <pubDate>Fri, 01 Jul 2022 11:52:22 GMT</pubDate>
            <atom:updated>2022-07-01T11:55:35.840Z</atom:updated>
            <content:encoded><![CDATA[<figure><img alt="" src="https://cdn-images-1.medium.com/max/397/1*jazBc5Vo_4gnqjHYsUFStw.png" /></figure><p>1.Cypress and Selenium are test automation tools used for functional testing of web applications by automating browser actions.</p><p>2. Selenium has been a widely-used tool for years, whereas Cypress is a recently introduced tool in the test community.</p><p>3. In spite of Cypress being recently introduced, it has gained significant traction.</p><p>So, the question is, how does Cypress compare to Selenium? Is Cypress a better alternative to Selenium?</p><p>Before we go into the difference between selenium and cypress, we have to know what selenium is and what cypress.</p><p><strong>Selenium:</strong></p><p>Selenium is an open-source automation tool that automates web browsers. It provides a single interface that lets you write test scripts in programming languages like Java, Ruby, Node.js, PHP and etc. A browser driver then executes these scripts on a browser instance on your device.</p><p><strong>Cypress:</strong></p><p>Cypress is also Open source test automation tool for testing web applications. Cypress is the new standard in front-end testing that every developer and QA engineer needs. Cypress helps developers and tester to create web automation scripts using JavaScript.</p><p>Now we look into the difference between selenium and cypress. we have identified many differences.</p><ol><li><strong>Architecture:</strong></li></ol><figure><img alt="" src="https://cdn-images-1.medium.com/max/386/1*I7yX3sJYPQFXQ4XBDK1fjw.png" /></figure><p>In <strong>Selenium</strong>, It has Webdriver API which interacts between Browser and Browser drivers. Selenium consists of 4 layers. JSON wire protocol, Browser Drivers, Browsers and Selenium client library.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/277/1*tJEu6too2uhmNiPvoS5ZNQ.png" /></figure><p><strong>Cypress</strong> — Unlike other testing tools which work outside of the browser, Cypress is present inside the browser. With the help of the Node.js server, it interacts with both the front and back end of the applications.</p><p><strong>2. Targeted Audience</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/259/1*hDlkcvQ33SoR62N28zCSCw.png" /></figure><p><strong>Selenium</strong> can be used only by Testing Team whereas <strong>Cypress</strong> can be used by both developers and testing team.</p><p><strong>3. Language Supported</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/299/1*QnzvPyGUUFMd4RIdfn96GQ.png" /></figure><p><strong>Selenium</strong> supports many programming languages like Java, JavaScript, Python, Ruby, C#, PHP, Perl, etc</p><p>But <strong>Cypress</strong> supports only JavaScript.</p><p><strong>4. Browser Supported</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/400/1*Wwc5B3tghkhkIe0V9wU5wA.png" /></figure><p><strong>Selenium</strong> supports Chrome, Firefox, Edge, IE, Safari and Opera whereas <strong>Cypress</strong> supports Chrome, Firefox, Edge, Electron and Brave.</p><p><strong>5. Framework Supported</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/360/1*Sa5NTnNCOFBZYChsL0Fagw.png" /></figure><p><strong>Selenium</strong> has a long list of framework support like JUnit, TestNG, PyUnit, Jbehave, Behave, Gauge, NUnit, Cucumber, Robot, Mocha and more.</p><p>But <strong>Cypress</strong> supports Mocha Only.</p><p><strong>6. Operating Systems</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*4QYFvCiyP2VwmhzJcb_WJg.png" /></figure><p><strong>Selenium</strong> supports Windows, Mac, Linux/Unix whereas<strong> Cypress</strong> supports Windows 7 and above, macOS, Linux, Fedora, and Debian.</p><p><strong>7. Setup Complexity</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/294/1*baP_RONsruITvyd1E_Ozrw.png" /></figure><p>Setup in <strong>Selenium</strong> is a bit challenging as it requires downloading browser-specific drivers and setting up the test environment. On the other hand setup in <strong>Cypress</strong> is simple, No dependencies or additional downloads are required.</p><p><strong>8. Integration with other tools</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/272/1*7_AQXt0kNYnmvRMpgU10jw.png" /></figure><p>For <strong>Selenium</strong>, a wide range of integration options are available CI/CD tools, reporting tools, and many more but with <strong>Cypress</strong> limited integration support with CI/CD tools when we compare them.</p><p><strong>9. Driver Dependency</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/218/1*Qp4Diuu_jRPzf25K8gLgBA.png" /></figure><p>In <strong>Selenium</strong>, an Appropriate browser driver has to be installed so that the test script can talk to the corresponding web browser. But there is no such layer of a driver in <strong>Cypress</strong> it directly interacts with web browser.</p><p><strong>10. iFrame</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/313/1*tJnnwuRlTMMp4mx7HIsTNg.png" /></figure><p>iFrame has very good support in <strong>Selenium</strong> but in <strong>Cypress</strong> we have a workaround.</p><p><strong>11. Execution Speed</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/300/1*fUWlE2eviEX0f2y0KTODMQ.png" /></figure><p>The execution speed of <strong>Selenium</strong> is comparatively slower than <strong>Cypress</strong>.</p><p><strong>12. Automatic waiting</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/198/1*hG4KdoG81n3wLvl1UcreGg.png" /></figure><p>No such support in<strong> Selenium</strong> but in<strong> Cypress </strong>no requirement to add waits or sleep in the tests. Cypress automatically waits for commands and assertions before moving to the next instruction.</p><p><strong>13. Default Screenshot and Videos</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/272/1*jbBNRCIa-8pDn5NVcBBwTw.png" /></figure><p>In <strong>Selenium</strong> we need to write code for support adding screenshots and videos. But <strong>Cypress</strong> we have direct support for it.</p><p><strong>14. Mocking Server</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/316/1*Gz0m5aECeDfyrIxjzK8uvQ.png" /></figure><p>No such thing in <strong>Selenium</strong> but <strong>Cypress</strong> has built-in facilities for mocking server responses.</p><p><strong>15. Documentation and Community support</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/333/1*oqj2h2HAubekAaAWgf9VZg.png" /></figure><p><strong>Selenium</strong> is Well established documentation and firm community support from users across the globe whereas <strong>Cypress</strong> is Very intuitive documentation along with a rapidly growing community.</p><p><strong>16. Parallel Testing</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/279/1*6ol2RClvZXvbrF5TaPviEQ.png" /></figure><p>Both <strong>Selenium</strong> and<strong> Cypress</strong> support Parallel Testing.</p><p><strong>17. Mobile Testing</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/241/1*AIl9qVVBIGXw1YaY2PeGyw.png" /></figure><p>Mobile testing is directly not supported in <strong>Selenium</strong> but using Appium, we can do it. But no support in <strong>Cypress</strong> for mobile testing.</p><p><strong>Conclusion:</strong></p><p>Although Selenium and Cypress are both designed to automate browsers for testing purposes, they differ considerably in terms of architecture and performance. A better approach would be evaluating both the tools and seeing how Selenium and Cypress can be used to improve test coverage for your project.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=3890017ad6c" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[Cypress Automation Framework with JavaScript]]></title>
            <link>https://medium.com/@pavithradevi.c/cypress-automation-framework-with-javascript-a96593f8fa8a?source=rss-42b699077c17------2</link>
            <guid isPermaLink="false">https://medium.com/p/a96593f8fa8a</guid>
            <category><![CDATA[cypress-testing]]></category>
            <category><![CDATA[javascript]]></category>
            <category><![CDATA[cypress-automation]]></category>
            <category><![CDATA[cypress]]></category>
            <category><![CDATA[cypress-installation]]></category>
            <dc:creator><![CDATA[Pavithradevi C]]></dc:creator>
            <pubDate>Tue, 28 Jun 2022 08:43:06 GMT</pubDate>
            <atom:updated>2022-06-28T08:43:06.262Z</atom:updated>
            <content:encoded><![CDATA[<h3><strong>Cypress</strong></h3><p>It’s a test automation tool, similar to Selenium WebDriver, WebDriverIO, TestCafe, and others.</p><p>Cypress is a web test automation framework; it helps developers and testers to create web automation scripts using JavaScript. JavaScript is popular with the Developer audience also. Just like other web automation frameworks, Cypress automation also has these stages.</p><p>1. Set up tests</p><p>2. Script the tests</p><p>3. Test Run</p><p>4. Debug the Tests.</p><p>Cypress is compared with Selenium, but their architecture is different. Cypress does not have a lot of restrictions as selenium has. It makes Cypress create your automation web scripts faster and easier. Using Cypress anything can be tested which is running on a Browser, following testing can be automated by Cypress</p><ol><li>Unit testing</li></ol><p>2. Integration testing</p><p>3. End-to-end testing</p><h4>Why is this tool generating so much interest?</h4><p>1. Cypress is also an Open-source test automation tool for testing web applications.</p><p>2. Cypress is the new standard in front-end testing that every developer and QA engineer needs.</p><p>3. Cypress helps developers and testers to create web automation scripts using JavaScript.</p><h3><strong>Architecture</strong></h3><p>Automation tools like Selenium work by running outside the browser. However, Cypress has a different architecture. It runs within the browser. Cypress is based on the server — Node.js.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/388/1*e2541DEIHenf2y3DzgAlCw.png" /></figure><p>There is a continuous interaction of Cypress with the Node.js and they work in coordination with each other. As a result, Cypress can be utilized for testing both the front and backend of the application.</p><p>Cypress is thus capable of handling the tasks performed in real-time on the UI and simultaneously can also perform the actions outside of the browser.</p><h4>Reasons to Use Cypress</h4><p>1. Cypress gives a fast and stable test execution as compared to other automation tools because of its Architectural design.</p><p>2. Cypress has the feature of screenshot capturing while test execution. It can also capture the video of the test suite if it is running from the command line Interface.</p><p>3. In the Developer tools section, it gives debugging option which helps developers to debug fast and in an easy.</p><p>4. Unlike other tools where wait and sleep are used to achieve synchronization in test runs, Cypress has an inbuilt feature which waits by default until the next action and waits before moving to the next step.</p><p>5. In Cypress we can see the response time of an activity which is useful for a unit testing perspective.</p><p>6. Cypress can be used with CI tools [Continues Integration tools-Jenkins].</p><p>7. With the help of the Viewport sizing feature, cypress can check the responsiveness of a web page.</p><p>8. Cypress provides test case status in a clear format; it displays the count of test cases which are passed or failed.</p><p>9. Cypress has a good capability of error logging, which clearly describes the reason for any error or failure.</p><p>10. Cypress has good documentation support, which helps developers and testers to write critical tests.</p><h4>Advantages of Cypress</h4><p>1. <a href="https://www.browserstack.com/guide/cypress-framework-tutorial">Cypress framework</a> captures snapshots at the time of test execution. This allows QAs or developers to hover over a specific command in the Command Log to see exactly what happened at that step.</p><p>2. One does not need to add <a href="https://www.browserstack.com/guide/wait-commands-in-selenium-webdriver">explicit or implicit wait commands</a> in test scripts, unlike Selenium. Cypress waits automatically for commands and assertions.</p><p>3. Developers or QAs can use Spies, Stubs, and Clocks to verify and control the behaviour of server responses, functions, or timers.</p><p>4. The automatic scrolling operation ensures that an element is in view before performing any action (for example Clicking on a button)</p><p>5. Earlier Cypress supported only Chrome testing. However, with recent updates, <a href="https://www.cypress.io/blog/2020/02/06/introducing-firefox-and-edge-support-in-cypress-4-0/">Cypress now provides support for Firefox and Edge browsers.</a></p><p>6. As the programmer writes commands, Cypress executes them in real-time, providing visual feedback as they run.</p><p>7. Cypress carries excellent documentation.</p><h4>Limitations of Cypress</h4><ol><li>One cannot use Cypress to drive two browsers at the same time</li></ol><p>2. It does not provide support for multi-tabs</p><p>3. Cypress only supports JavaScript for creating test cases</p><p>4. Cypress does not provide support for browsers like Safari and IE now.</p><p>5. Limited support for iFrames</p><h3>Cypress Environment Setup</h3><p>For Cypress environment setup, follow the steps below</p><p><strong>Step:1 — Install node.js</strong></p><p>visit the link: <a href="https://nodejs.org/en/download/">https://nodejs.org/en/download/</a></p><p>The screen that will appear is given below</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*ab8XS5SSF2sUu1FPlumsHQ.png" /></figure><p>There shall be both Windows and macOS installers. We must get the package as per the local operating system.</p><p>For a 64- bit Windows configuration, the following pop-up comes up to save the installer.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/530/1*nnLcK_dmve1IABB3ORIa-w.png" /></figure><p>Once the installation is done, a NodeJS file gets created in the Program Files. The path of this file should be noted. Then, enter the path in environment variables.</p><p>Once the path of the node.js file is set.</p><p>You can check the node version and npm version in the command prompt.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*4NjzcSgCRnC7kHzsx20sCw.png" /></figure><p>Next, we need to have a JavaScript editor to write the code for Cypress.</p><p><strong>Step:2 — Install Visual Studio code</strong></p><p>Visit the link to download the Visual studio code — <a href="https://code.visualstudio.com/download">https://code.visualstudio.com/download</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*pmzWl7h0dlrCpmCD0Ko4Vw.png" /></figure><p>From there you can choose the package based on the Operating system.</p><p>Once the executable file is downloaded, and all the installation steps are completed, the Visual Studio Code gets launched.</p><p><strong>Step:3 — Create a new folder for Cypress Automation Project</strong></p><p>we shall create an empty folder (say cypress) in any desired location.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/600/1*FpGhD53HBMUAZNzgnU4zYw.png" /></figure><p><strong>Step:4 — Open the folder in Visual Studio code</strong></p><p>Select the option Open Folder from the File menu. Then, add the Cypress folder (that we have created before) to the Visual Studio Code.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/283/1*WC-fHbALmcta3mv5piFs0w.png" /></figure><p><strong>Step:5 — Open VS code terminal and run the command npm init -y</strong></p><p>This command is an initialize, and it is used to make a package.json file for your project frontend. A package.json file is a file that contains information about the project’s packages and dependencies. It also contains metadata for the project such as version number, author, and description.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*MY6isPCghu0-pmwYKxbNoA.png" /></figure><p>Once done, the package.json file gets created within the project folder with the information we have provided.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*3GeKuIKfWQJSx-2Rk71obw.png" /></figure><p>In package.json, you can give the description like My first cypress project.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/618/1*0lMWjOaQLGU6VKiPPJD_8w.png" /></figure><p><strong>Step:6 — Install Cypress npm install cypress</strong></p><p>This will install Cypress locally as a dev dependency for your project. During the installation, we can ignore all warnings and notices that we get. Once the installation is successful, we could see a node modules folder and a package-lock.json file being created.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*tDWWhXsnqw7c0L8qq-faKQ.png" /></figure><p><strong>Step:7 — You can check the cypress version by using the command npx cypress -v or npx cypress -version</strong></p><p>Using this command, we can verify what cypress packages we installed are and what version is</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*XGzGX0mEH2dKbh3D_21Crw.png" /></figure><p><strong>Step:8 — Open cypress using npx cypress open</strong></p><p>This command will open the cypress window. Cypress will automatically find and allow you to use the browsers installed on your system. If found, the specified browser will be added to the list of available browsers in the Cypress App.</p><p>With the help of the cypress window, we can run the scripts.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*4C3-fSOhbIVf8iOy2RuyJg.png" /></figure><p>If you face any problems after using the npx cypress open command. Use this command npx cypress verify and then use npx cypress open</p><p><strong>You can see the project structure.</strong></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/282/1*UysN-J7Kpev-2QfY21tFLw.png" /></figure><h3><strong>Cypress Folder Structure:</strong></h3><p>After installing Cypress, it will create a recommended folder structure for you. There are four significant folders:</p><p>1. <a href="#fixtures">Fixture</a>s</p><p>2. <a href="#integration">Integration</a></p><p>3. <a href="#plugins">Plugins</a></p><p>4. <a href="#support">Support</a></p><h4>1. Cypress Fixtures Folder</h4><p>We use this folder to store data objects or external pieces of static data that we use throughout the tests; you will be typically using them with cy.fixture command. Usually, the data is stored in JSON format.</p><p><strong>Fixtures</strong> − Test data in form of key-value pairs for the tests are maintained here.</p><h4>2. Cypress Integration Folder</h4><p>The next folder is integration; This is the main folder to store all your test. We add the Basic, End to End Test, Visual or Cucumber test here. All your spec files will be here. Test file can be written as .js, .jsx, .coffee and .cjsx.</p><p>Earlier, we executed the script from this example folder; From the example folder, you can refer to different commands in Cypress; this will be extremely helpful during our script development.</p><p><strong>Integration</strong> − Test cases for the framework are maintained here.</p><h4>3. Cypress Plugins Folder</h4><p>It has its own index.js file. Put here your custom plugin code. You can find different plugins on the cypress.io website. The plugin file is a particular file that executes in Node before the project is loaded, before the browser launches, and during your test execution.</p><p>While the Cypress tests execute in the browser, the plugin file runs in the background Node process, giving your tests the ability to access the file system and the rest of the operating system by calling the cy.task() command.</p><p>The plugins file is an excellent place to define how you want to bundle the spec files via the preprocessors, find and launch the browsers via the browser launch API, and other things.</p><p><strong>Plugins</strong> − Cypress events (prior and post events to be executed for a test) are maintained here.</p><h4>4. Cypress Support Folder</h4><p>There are two files inside the support folder: commands.js and index.js</p><p><strong>1.command.js: </strong>is the file where you add your commonly used functions and custom commands. It includes functions you may call to use in different tests, such as the login function. Cypress created some functions for you, and you can override them here if you want.</p><p><strong>2. index.js:</strong> This file runs before every single spec file. This file is a suitable place to put global configuration and behavior that modifies Cypress like before or before each. By default, it imports only commands.js, but you can import or require other files to keep things organized.</p><p>Cypress recommends the above folder. However, you can modify the folder configuration in your configuration file. <strong>cypress.json</strong> is the main configuration file; you can override different default settings for Cypress here.</p><p><strong>Support</strong> − Reusable methods or customized commands, which can be utilized by test cases directly, without object creation are created here.</p><p>Apart from the above four folders, we have a few Asset Folders like <strong>Screenshot</strong>, <strong>Download</strong>, and <strong>Video </strong>to store different related files, which we will discuss later.</p><p><strong>node modules</strong> − Project dependencies from the npm are maintained in this folder. It is the heart of the Cypress project execution.</p><p><strong>cypress.json</strong> − Default configurations are set in this folder. The values of the current configurations can be modified here, which overrules the default configurations.</p><p><strong>package.json</strong> − Dependencies and scripts for the projects are maintained in this folder.</p><h3><strong>First Test:</strong></h3><p>Cypress has adopted Mocha’s syntax for the development of test cases, and it uses all the fundamental harnesses that Mocha provides. Below are a few of the main constructs which we majorly use in Cypress test development:</p><p><strong>Basic Commands:</strong></p><p><strong>1- cy.visit()</strong>: to navigate to the specific website</p><p><strong>2 - cy.contains()</strong>: to get the dom element containing text</p><p><strong>3 - cy.log()</strong>: to display cypress console logs during execution</p><p><strong>4 - cy.get()</strong>: to get dom element in cypress</p><p><strong>5 - cy.url()</strong>: to Get the current URL</p><p><strong>6 - describe()</strong>: It is simply a way to group our tests. It takes two arguments, the first is the name of the test group, and the second is a callback function.</p><p><strong>7 - context()</strong>: It is just an alias for describe ().</p><p><strong>8 - it()</strong>: We use it for an individual test case. It takes two arguments, a string explaining what the test should do, and a callback function which contains our actual test.</p><p><strong>9 - .type()</strong>: Type into a DOM element.</p><p><strong>10 - before()</strong>: It runs once before all tests in the block.</p><p><strong>11 - after()</strong>: It runs once after all tests in the block.</p><p><strong>12 - beforeEach()</strong>: It runs before each test in the block.</p><p><strong>13 - afterEach()</strong>: It runs after each test in the block.</p><p><strong>14 - cy.only()</strong>: To run a specified suite or test, append “. only” to the function.</p><p><strong>15 - cy.skip()</strong>: To skip a specified suite or test, append “. skip<strong>()</strong>” to the function.</p><p>You can write the test in the Integration folder</p><p>First, add a new file named <strong>“FirstTest.js”</strong> under the <strong>“advanced-examples”</strong> folder, by right-clicking on the folder and selecting the option <strong>“New File</strong>”:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/679/1*aLIVq77rxPsvOC62TbOc_Q.png" /></figure><h3><strong>Test Execution:</strong></h3><p>After you open Cypress using the npx cypress open command in Terminal, the <strong>Test Runner window</strong> will open, which will show the test case “<strong>FirstTest.js</strong>”, as shown below.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*O7hW4lXlfsc4ovhHUeM3zA.png" /></figure><p>The Cypress Test Runner tries to find all compatible browsers on the user’s machine. The drop-down to choose a different browser is in the top right corner of the Test Runner.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*6iyjf5Fo1Upc7ufpt7b_RA.png" /></figure><p>Now, to run the test case that we created in our previous tutorial which was <strong>FirstTest.js</strong>, just click on the test case on the runner window as highlighted in the above screenshot, it will open the browser and will run all the steps in the test case. You will see a screen below showing the execution of the test case:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*giqksNTdBPsBlsm4FrEyPA.png" /></figure><p><strong>Second Test:</strong></p><p>The Script is written Positive Test Case filling all the details in contact-us.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*bp4FJNq7rbxXlPThl4gsxw.png" /></figure><p>Below is the output of the Test Script filling all the details in contact-us.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*kIStc9Crc_ckWcag84mWDw.png" /></figure><p><strong>Third Test Case:</strong></p><p>The script is written Negative Test Case without filling email field in contact-us.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*1mamxvvDvUJBBB_5GjY0WQ.png" /></figure><p>Below is this output of the Test Script without filling the email field in contact-us.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*5cr1OldNx4Xkx9r9MIID4Q.png" /></figure><h3><strong>Conclusion:</strong></h3><p>Cypress is a great tool for those who want to create useful end-to-end tests with little effort. It supports the testing of all types of web elements easily using powerful in-built commands. Cypress provides you with a visual interface to indicate whether the test commands have been successfully executed, passed, or failed</p><p>Thanks, and I hope this article helps you.</p><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=a96593f8fa8a" width="1" height="1" alt="">]]></content:encoded>
        </item>
        <item>
            <title><![CDATA[EXPLORING UNIT TESTING WITH JUNIT TEST FRAMEWORK]]></title>
            <link>https://medium.com/@pavithradevi.c/exploring-unit-testing-with-junit-test-framework-d47f92137800?source=rss-42b699077c17------2</link>
            <guid isPermaLink="false">https://medium.com/p/d47f92137800</guid>
            <category><![CDATA[test-driven-development]]></category>
            <category><![CDATA[unit-testing]]></category>
            <category><![CDATA[junit]]></category>
            <category><![CDATA[testing]]></category>
            <category><![CDATA[maven]]></category>
            <dc:creator><![CDATA[Pavithradevi C]]></dc:creator>
            <pubDate>Mon, 28 Mar 2022 14:10:12 GMT</pubDate>
            <atom:updated>2022-03-28T14:10:12.499Z</atom:updated>
            <content:encoded><![CDATA[<blockquote>EXPLORING UNIT TESTING WITH JUNIT TEST FRAMEWORK</blockquote><p>Before we go further into the JUnit framework, let’s talk a little about Unit Testing.</p><p><strong>Unit testing</strong>, as the name suggests, refers to the <strong>testing of small segments of code</strong>. Here, a unit indicates the smallest bit of code that can be fetched out of the system. This small bit can be a <strong>line of the code, a method, or a class</strong>. The smaller the chunk of code, the better it is, as smaller chunks will tend to run faster. And this provides a better insight into the code and its performance.</p><p><strong>JUNIT</strong></p><p>JUnit is a unit testing framework for the Java programming language. JUnit has been important in the development of <strong>test-driven development </strong>and is one of a family of unit testing frameworks collectively known as <strong>xUnit</strong>, that originated with JUnit. The unit promotes the idea of “<strong>first testing then coding</strong>”, which emphasizes setting up the test data for a piece of code that can be tested first and then implemented. This approach is like “<strong>test a little, code a little, test a little, code a little</strong>”. It increases the productivity of the programmer and the stability of program code, which in turn reduces the stress on the programmer and the time spent on debugging.</p><p><strong>Features of JUnit</strong></p><p><strong>1. Open Source Framework</strong></p><p><strong>2. Provide Annotation</strong> — To identify test methods</p><p><strong>3. Provides Assertion</strong> — For Testing expected results</p><p><strong>4. Provides test runners</strong> — Running tests</p><p><strong>5. Improves Code quality</strong> — It allows faster code writing, which results in an increase in the code’s quality.</p><p><strong>6. Automated Test Running</strong> — The test results do not require manual checking. All the tests run automatically on JUnit.</p><p>7. <strong>Easily interpretable Results</strong> — The test results are represented interactively by showing test progress in a bar, thus making them easily interpretable.</p><p><strong>How to install JUnit in Eclipse</strong></p><p><strong>Part 1: Create Maven Project</strong></p><p>File-&gt;click new -&gt;Maven-&gt;maven project -&gt;next -&gt;dialog box will appear.</p><p>It asks for group id, artifact name.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/529/1*gPTQaoBJzBqQ-YF8R1cJfQ.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/532/1*xg1s7H7OiLkBPLc1S5XmxA.png" /></figure><p><strong>Group id </strong>represents package name</p><p><strong>Artifact id</strong> represents class name</p><p>Then click finish</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/498/1*2UaeeKImX_mwl9nmawB4aA.png" /></figure><p>Now you will see a structured project gets built.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/316/1*bCN6pV8cOeyNuy5yG_HTBA.png" /></figure><p><strong>Why we prefer maven project than java project means</strong>,</p><ol><li>Maven can add all the dependencies required for the project automatically by reading the pom file.</li></ol><p>2. One can easily build their project to a jar, war etc. as per their requirements using Maven.</p><p>3. Maven makes it easy to start a project in different environments and one doesn’t need to handle the dependencies injection, builds, processing, etc.</p><p>4. Adding a new dependency is very easy. One has to just write the dependency code in the pom file.</p><p><strong>Part 2: Add Dependencies for JUnit in pom.xml</strong></p><p><a href="https://mvnrepository.com/artifact/junit/junit/4.12">Maven Repository: junit &quot; junit &quot; 4.12</a></p><figure><img alt="" src="https://cdn-images-1.medium.com/max/697/1*QjvWOWFlr8BPjTj57_LEtw.png" /></figure><p><strong>Part 3: verify Junit setup</strong></p><p>You can create a simple JUnit test to verify JUnit setup. See below test class:</p><p><strong>Step 1</strong>: Create a java class named TestJUnit.java and provide a simple assert statement.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/423/1*lO_66ITjXOScQfKU-0BaJA.png" /></figure><p><strong>Step 2</strong>: To execute the test, follow below steps:</p><p>1.Right click on TestRunner.java and click on “Run As” as shown below</p><p>2.Another window will be open once you click on “Run As”, click on “1 JUnit Test” as shown below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*-7TENenLXU6Frc3F-MSU0w.png" /></figure><p><strong>Step 4</strong>: Here is the output or result for your test. If it is successfully executed, it will show a green check mark in front of it.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/508/1*UCGb0FS7MV954j8ycx0HSw.png" /></figure><p><strong>JUnit Annotations:</strong></p><p><strong>1.@Test</strong></p><p>The Test annotation tells JUnit that the public void method to which it is attached can be run as a test case.</p><p><strong>2.@Before</strong></p><p>Several tests need similar objects created before they can run. Annotating a public void method with @Before causes that method to be run before each Test method.</p><p><strong>3.@After</strong></p><p>If you allocate external resources in a Before method, you need to release them after the test runs. Annotating a public void method with @After causes that method to be run after the Test method.</p><p><strong>4.@BeforeClass</strong></p><p>Annotating a public static void method with @BeforeClass causes it to be run once before any of the test methods in the class.</p><p><strong>5.@AfterClass</strong></p><p>This will perform the method after all tests have finished. This can be used to perform clean-up activities.</p><p><strong>6.@Ignore</strong></p><p>The Ignore annotation is used to ignore the test and that test will not be executed.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/403/1*OaUgb7REq_iQUx0bLNDBpg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/712/1*_3f1ZGWcRcc0Y3-p5wY1Ow.png" /></figure><p><strong>JUnit Assertion</strong></p><p>Assert is a method useful in determining Pass or Fail status of a test case, The assert methods are provided by the class org.junit.Assert which extends java.lang.Object class.There are various types of assertions like Boolean, Null, Identical etc.</p><p>Junit provides a class named Assert, which provides a bunch of assertion methods useful in writing test cases and to detect test failure. The assert methods are provided by the class<strong> org.junit.Assert</strong> which extends<strong> java.lang.Object</strong> class. Some of the Assertions methods:</p><p><strong>1.void assertEquals(boolean expected, boolean actual)</strong></p><p>Checks that two primitives/objects are equal.</p><p><strong>2.void assertTrue(boolean condition)</strong></p><p>Checks that a condition is true.</p><p><strong>3.void assertFalse(boolean condition)</strong></p><p>Checks that a condition is false.</p><p><strong>4.void assertNotNull(Object object)</strong></p><p>Checks that an object isn’t null.</p><p><strong>5.void assertNull(Object object)</strong></p><p>Checks that an object is null.</p><p><strong>6.void assertSame(object1, object2)</strong></p><p>The assertSame() method tests if two object references point to the same object.</p><p><strong>7.void assertNotSame(object1, object2)</strong></p><p>The assertNotSame() method tests if two object references do not point to the same object.</p><p><strong>8.void assertArrayEquals(expectedArray, resultArray);</strong></p><p>The assertArrayEquals() method will test whether two arrays are equal to each other.</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/476/1*-5d3fHCjQFmLzapAREI3Zg.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/547/1*ur2lZ4dZ_DX5l0300kK1cg.png" /></figure><p><strong>JUnit Test Runner and Test Suites</strong></p><p>If we want to execute multiple tests in a specified order, it can be done by combining all the tests in one place. This place is called as the TestRunner. More details on how to execute test suites and how it is used in JUnit will be covered in this Article.</p><p>1.JUnitCore class is used to execute these tests.</p><p>2.A method called runClasses provided by org.junit.runner.JUnitCore, is used to run one or several test classes.</p><p>3.Return type of this method is the Result object (org.junit.runner.Result), which is used to access information about the tests. See the following code example for more clarity.</p><p><strong>1. </strong>Created 2 classes (A.java and B.java)</p><p><strong>A.java and B.java</strong></p><p>We need to create a test class with a test method annotated with @Test and @Ignore as given below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/698/1*Rn1FHo491FfcO6y5ETBXkA.png" /></figure><p><strong>2</strong>.To execute our test method (above) ,we need to create a <strong>test runner</strong>.</p><p>In the test runner we have to add test class as a parameter in JUnitCore’s runclasses() method. It will return the test result, based on whether the test is passed or failed.</p><p>And we used some methods like getRunCount(), getIgnoreCount(), getFailureCount(), getRunTime(), wasSuccessful() in <strong>import org.junit.runner.Result</strong></p><p>a. getRunCount() — It will give how many test method is executed</p><p>b. getIgnoreCount() — It will give how many test method is ignored using @Ignore annotation</p><p>c. getFailureCount() — It will give how many test method is failed</p><p>d. getRunTime() — It will give how much time is taken to execute test method in ms</p><p>e. wasSuccessful() — It will give Suite is True or False</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/484/1*ynbPyDI79MzxtVB44gED0Q.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/339/1*LSTFR6SyR81ovtxCM14ioQ.png" /></figure><p>2. To create a <strong>testSuite</strong> you need to first annotate the class with</p><p><strong>@RunWith(Suite.class)</strong> and <strong>@SuiteClasses(class1.class2…..).</strong></p><p>TestSuite.java is a simple class annotated with @RunWith and @Suite annotations. You can list out number of .classes in the suite as parameters as given below:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/531/1*v7XeIEe-5E5hWyd28iPgXg.png" /></figure><p>After executing TestSuite.java which contains a suite having A.java and B.java, you will get below output:</p><figure><img alt="" src="https://cdn-images-1.medium.com/max/215/1*Z9lt4n7eng-Tf0QNk4U4kw.png" /></figure><figure><img alt="" src="https://cdn-images-1.medium.com/max/264/1*nr-_aCg0j9pdladADDQnFg.png" /></figure><img src="https://medium.com/_/stat?event=post.clientViewed&referrerSource=full_rss&postId=d47f92137800" width="1" height="1" alt="">]]></content:encoded>
        </item>
    </channel>
</rss>