• 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
  • Interview Questions
  • Java
  • Java Programs
  • Selenium
  • Selenium Programs
  • Manual Testing
  • Test Cases
  • Difference
  • Tools
  • SQL
  • Contact Us
  • Search
SoftwareTestingo » Selenium » Free Selenium Tutorial » TestNG Inheritance – With Simple Example Program

TestNG Inheritance – With Simple Example Program

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

What We Are Learn On This Post

  • TestNG Inheritance Implementation

TestNG Inheritance: As we have already learned how testNG supports both method overloading and method overriding in a testNg class. Now we are going to discuss one more important oops concept inheritance with TestNG.

If you can recall that inheritance is nothing a process by which one class acquires the data member and member function of other class. If you don’t know in detail about inheritance, then no need to worry because we have already covered about inheritance in Java in detail there.

TestNG Inheritance Implementation

Let’s try to find out is TestNg support the feature inheritance or not, with some simple program:

Superclass:

package InheritanceInTestNG;
import org.testng.annotations.Test;
public class SuperTestNgClass 
{
   @Test
   public void superTestNgMethod()
   {
      System.out.println(“Super testng method”);
   }
}

Child Class with Extends Superclass:

package InheritanceInTestNG;
import org.testng.annotations.Test;
public class SubTestNGClass extends SuperTestNgClass
{

   @Test
   public void subTestNgMethod()
   {
      System.out.println("Sub testng method");
   }
}

Now create a test suite that has both super and child classes and execute that suite.

As in the output, you can say that we have got both class methods are executed. As a part of the superclass, the method is executed, and as the child class has both super and child class methods, the output has all the methods, which mean both super and child class methods.

Source: link

    Filed Under: Free 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

    Categories

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