Thursday, June 27, 2024

TestNG Introduction

 TestNG  :

What is TestNG? 

TestNG is a testing framework inspired by JUnit and NUnit but designed to cover a wider range of test categories, from unit tests to integration tests. 

Why should we go for TestNG?

TestNG offers several advantages that make it a preferred choice for testing: 

You can run a single class or multiple classes.

Example: Running as a Java application

A.Java

B.Java

C.Java 

You can group test cases for different types of testing such as smoke tests, regression tests, and integration tests.

  ex:   smoke test cases

        regression test cases

      Integration test cases

 

You can run test cases based on priority

       test(priority =0)  --> 1st

       test(priority =1)  --> 2nd

 

You can run test cases in parallel--> parallel testing

             tc1

            tc2

            tc3

 

            Can run all  test cases at the same time

            tc1  6pm

            tc2  6pm

            tc3  6pm

 

TestNG allows you to generate reports and log user-defined messages.

            Java -   Syso.println("");

      Selenim -  will not generate any automation results - so we go for TestNG

 

We can perform DDT

            Data Driven Testing :  testing the application with multiple/different sets of data

 

Example 1: Login functionality with different users and passwords.        

            user     pwd

            -----------------

            ram,     mercury         

            Sita,     mercury

            Raju,   mercury

 

Example 2: Creating orders with different product names, quantities, and addresses.

                                    Productname Qty   Address

                                    ------------------------------

                                    Samsung,        2,         BNG

                                    Shampoo,        3,         CHN

                                    Santoor,          5,         HYD

 

 

 

Download testNG:

Refer: https://www.guru99.com/install-testng-in-eclipse.html

To install TestNG in Eclipse, follow these steps:

  1. Go to the Eclipse Help menu.
  2. Select Eclipse Marketplace.
  3. In the search bar, type "TestNG" and press Enter.
  4. You will see "TestNG for Eclipse" plugin. Click the Install button.
  5. Click Next.
  6. Accept the terms by selecting the Accept terms... radio button.
  7. Click Next.
  8. If any warning messages appear, click OK and continue.
  9. Restart Eclipse.

Verify TestNG Installation

To verify if TestNG is installed, follow these steps:

  1. Go to Window > Show View > Other.
  2. Search for "TestNG".
  3. If TestNG is installed, it will display the 'TestNG' option.
  4. If TestNG is not installed, it will not display the 'TestNG' option.

 

TestNG can be referred to as both a plugin and a library.

Add TestNG Library

To add the TestNG library to your project, follow these steps:

  1. Select your project.
  2. Right-click and select Properties.
  3. Go to Java Build Path.
  4. Click the Libraries tab.
  5. Click/ Select Class Path
  6. Click Add Library.
  7. Select the TestNG option and click Next.
  8. Click Apply and Close.
  9. Check the 'TestNG' library file added to your project.

To verify, check in the Project Explorer window to see if TestNG exists.

No comments:

Post a Comment

git commands MCQ

 Here are some multiple-choice questions (MCQs) on Git commands relevant for Selenium: 1. Which Git command is used to clone a remote reposi...