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

SoftwareTestingo - Jira Selenium Protractor Testing SDLC Agile Methodology

Java Selenium Tutorial & Testing Interview Questions

  • Home
  • Interview Questions
  • Java
  • Java Programs
  • Test Cases
  • Selenium
  • Manual Testing
  • Difference
  • Search
SoftwareTestingo » Selenium » 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: Selenium Tutorial

    Reader Interactions

    Leave a Reply Cancel reply

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

    Primary Sidebar

    Join SoftwareTestingo Telegram Group

    Tutorials Important Links

    • Software Testing Jobs
    • Manual Testing Tutorial
    • Selenium Tutorial
    • Core Java Tutorial
    • TestNG Tutorial
    • Java Programs
    • Selenium Programs
    • Manual Test Cases
    • Interview Tips
    • Contact US
    • www.softwaretestingo.com

    Important Links

    • Software Testing Interview Questions
    • Agile Interview Questions
    • Manual Testing Interview Questions
    • Testing Interview Questions
    • Selenium Interview Questions
    • Selenium Real Time Interview Questions
    • Selenium WebDriver Interview Questions
    • Automation Framework Interview Questions
    • Appium Interview Questions
    • TestNG Interview Questions
    • Java Interview Questions
    • Core Java Interview Questions

    Categories

    Copyright © 2021 SoftwareTestingo.com ~ Contact Us ~ Sitemap ~ Privacy Policy