Skip to content

Make Selenium Easy

And Keep It That Way

  • Home
  • Share
  • Toggle search form

TestNG Tutorials 5: How To Create And Run A TestNG Class

Posted on 12/11/2024 By admin

Hello Folks,

In this post, we will see some basics implementation of TestNG.

A class is called TestNG class if it has annotations provided by TestNG. TestNG provides an annotation called “Test” which you need to use for any method which has some business logic to verify. When you add this “Test” annotation, you DON’T Require to include “public static void main(String args[])” method in your class. Main method is starting point of execution of a java program. But when you add “Test” annotation with methods, JVM run those methods directly.

Suppose, you need to verify below sceanrios:

  1. Are String “Selenium WebDriver” and “Selenium” equal?
  2. Is variable ‘x’ is greater than zero?

You will create two methods for each scenario and need to add “@Test” annotation.

Steps to be followed:

  1. Create a plain java class.
  2. Create two methods named “verifyString” and “verifyVariableValue”.
  3. Add annotation as “@Test” both the methods.
  4. Run as a TestNG suite.

Java Program:

You need to run it as a TestNG test. Right click on Class Name in project hierarchy or right click on opened windows of program and select Run As-> TestNg test.

After running tests, you will can see output in two tabs: Console and Result of running class . It will show you how many tests are passed , failed and skipped. We will see these result tab in details in later posts. You can see single failure as your first test must be fail as “Selenium Webdriver” and “Selenium” both are not equal.

More about TestNG in upcoming posts. Stay tuned.

If you have any doubt, feel free to comment below. If you like my posts, please like, comment, share and subscribe. #ThanksForReading

#HappySelenium

Uncategorized

Post navigation

Previous Post: JAVA Topics
Next Post: Rūto – Get Started & Save Time in Finding Locators

Related Posts

October 10, 2017 – Make Selenium Easy Uncategorized
TestNG Tutorials 55: DataProvider in TestNG – Lazy Initialisation of DataProvider Method – Use of Iterator Return Type Uncategorized
Make Selenium Easy | Make Selenium Easy – Selenium Tutorials : End To End Uncategorized
read excel data using apache poi Uncategorized
Tools To Find XPath In Chrome Browser Uncategorized
Postman Tutorial Part 47 – Local or Temporary Variables in Postman Uncategorized

Recent Posts

  • Getting Started with Selenium 4: What Is New and How to Upgrade from Selenium 3
  • Manual Testing
  • Baby Steps To Become Efficient Selenium-Java Automation Tester
  • Features of Selenium 4.0.0 Release – Java Binding
  • Part 1: Handling Drop-down Created Using SELECT Tag In Selenium

Recent Comments

No comments to show.

Archives

  • April 2026
  • April 2025
  • March 2025
  • February 2025
  • January 2025
  • December 2024
  • November 2024
  • October 2024
  • September 2024
  • August 2024
  • April 2024
  • March 2024
  • February 2024
  • December 2023
  • October 2023
  • August 2023
  • November 2022
  • September 2022
  • August 2022
  • July 2022
  • May 2022
  • March 2022
  • October 2021
  • April 2021
  • March 2021
  • January 2021
  • December 2020
  • October 2020
  • September 2020
  • August 2020
  • June 2020
  • May 2020
  • April 2020
  • March 2020
  • February 2020
  • January 2020
  • December 2019
  • November 2019
  • October 2019
  • September 2019
  • August 2019
  • May 2019
  • December 2018
  • November 2018
  • October 2018
  • September 2018
  • August 2018
  • July 2018
  • January 2018

Categories

  • Getting Started
  • Uncategorized

Copyright © 2026 Make Selenium Easy.

Powered by PressBook Masonry Dark