• Skip to primary navigation
  • Skip to main content
  • Skip to primary sidebar

SoftwareTestingo - Interview Questions, Tutorial & Test Cases Template Examples

SoftwareTestingo - Interview Questions, Tutorial & Test Cases Template Examples

  • Home
  • Test Case Examples
  • Interview Questions
  • Interview Questions Asked
  • Java
  • Selenium
  • Manual Testing
  • SQL Tutorial For Beginners
  • Difference
  • Tools
  • Contact Us
  • Search
SoftwareTestingo » Selenium » Free Selenium Tutorial » Write First Test Case with TestNG [Step By Step Guide]

Write First Test Case with TestNG [Step By Step Guide]

Last Updated on: November 30, 2019 By Softwaretestingo Editorial Board

What We Are Learn On This Post

  • First Test case with TestNG Guide

First Test case Using TestNg: In this post, we are trying to learn how we can create our first test case by using TestNG. Before going through the application, verify that on your local machine, TestNG is installed or not.

If TestNG is not installed, then we have written a detailed article about that and by following that you can install TestNG on your local machine on your own without taking others’ help.

First Test case with TestNG Guide

If TestNG is already installed on your local machine, then follow the below steps to create TestNG class:

  • You can directly create a testNG class by pressing the CTRL + N and Select “TestNG Class” at the TestNG category and Click Next [OR] You can do the same by right click on the project – Select TestNg and after that, choose to Create TestNG class.
  • If you have already set up your project and when you are creating the test cases, then by default by default few things are auto pre polluted like source folder location and package name on the form. Enter a class name in the class name text box, and under that, you will get the different annotations, and there you need to select “@BeforeMethod,” “@AfterMethod,” and click Finish.
  • After Click on the finish, it will display a newly created testNG class under that package. In that class, you can see three empty methods with three different annotations like @Test, @BeforeMethod & @AfterMethod.
  • Let us Use those three methods and write the script for different purposes like
    @BeforeMethod: Launch Firefox and Direct to the SoftwareTestingo
    @Test: Get The Page Title
    @AfterMethod: Close The Browser

Source: Link

    Filed Under: Free Selenium Tutorial

    Reader Interactions

    Comments

    1. Avatar for AnupamaAnupama says

      February 28, 2022 at 10:05 AM

      Hi Team,

      Can you provide the project for selenium. Where we know how to do scripts for project.
      And also priority in TestNG.
      Thank You!

      Reply

    Leave a Reply Cancel reply

    Your email address will not be published. Required fields are marked *

    Primary Sidebar

    Join SoftwareTestingo Telegram Group

    Categories

    Copyright © 2023 SoftwareTestingo.com ~ Contact Us ~ Sitemap ~ Privacy Policy ~ Testing Careers