Follow Us:

Getting Started with TestNG – Writing & Running Your First Test Case

In this document, we will start writing our first TestNG test case and understand how TestNG executes our test methods without requiring a main method.


1️⃣ Creating the First TestNG Class


Step 1: Create a Java Class


📌 Project Structure:

Project: TestMave

├── src/main/java
│    
    ├  ── testng.tutorial (Package)
    │         
    ├── TestNGIntroduction.java (Class)

2️⃣ Writing a Simple Java Program

Before using TestNG, let's first write a simple Java program that prints a message to the console.

public class TestNGIntroduction {
    public static void main(String[] args) {
        System.out.println("Hello, Java!");
    }
}

What Happens Here?

The program runs as a Java application using the main method.

Output: "Hello, Java!" is printed to the console.