TestingDocs.com
    Software Testing website
    • Automation
      • Selenium
      • JBehave Framework
    • Tutorials
      • MySQL Tutorials
      • Testlink
      • Maven
      • Git
    • IDEs
      • IntelliJ IDEA
      • Eclipse
    • Flowcharts
      • Flowgorithm
      • Raptor
    • About

    Automation

    TestNG Automation Framework Questions

    In this post, lets look into some of the TestNG automation framework questions and answers to them.

    What is TestNG framework ?

    TestNG is inspired by JUnit and NUnit frameworks. It is an open-source framework for functional test automation. It provides an API for adding custom implementations as well. Also, TestNG has a better reporting structure and it provides XML and HTML default reports.TestNG is primarily used for functional testing, unlike JUnit which is mostly used for unit testing. In addition, we can drive testng different configuration runs using the XML file. Furthermore, TestNG methods are specified with @Test annotation in the code.

    What are TestNG framework features?

    Main TestNG features are:

    • Support for different annotations.
    • Flexibility using XML test suite file.
    • Test Parameters.
    • Test Groups.
    • Test Dependencies.
    • Parallel testing.
    • Data-driven testing using – @DataProvider, @Factory
    • Test Reports
    • Open API
    • Ability to run failed Tests

    Open  TestNG API .
    TestNG provides easy extension of API, this helps in adding custom extensions or plugins to the framework depending upon the requirement.

    What is method dependency in TestNG?

    Sample snippet below that depicts method dependency in TestNG framework.

    @Test() 
     public void method1(){ 
     System.out.println("method1"); 
     } 
      
       
     @Test(dependsOnMethods={"method1"}) 
     public void dependent(){ 
     System.out.println("This method depends on method1, this method will  
    skip if method1 fails"); 
     }

     

    What is @Factory annotation in TestNG?

    @Factory in TestNG framework creates tests dynamically at run-time. A factory method is defined by declaring @Factory above the respective test method. It is mandatory that a factory method should return an array of Object  i.e Object[]
    TestNG factory is used to create instances of test classes. This is useful if you want to run the test class any no of times.

    Example code snippet:

     
    public class SampleFactory
     {
      @Factory
      public Object[] factoryMethod()
     {
      Object[] object = new Object[5];
      for (int i = 0; i < 5 ; i++)
         {
         object[i] = new SampleTest();
           }
      return object;
      }
     }

     

    Related Posts

    Automation /

    Dart return Statement

    Emma Tool

    Automation /

    Code Coverage Tools

    Selenium 4 Automation Project

    Automation /

    Selenium 4 Project Setup on Ubuntu Linux

    Testing webpage mobile-friendliness using a tool

    Automation /

    Testing webpage mobile-friendliness using a tool

    Errors Code Testing Development

    Automation /

    Error Severity Metrics

    ‹ Unix Operating System for Beginners› JMeter Performance Testing Questions

    Recent Posts

    • Running Tests in Parallel with Selenium Grid
    • Advanced Selenium Features
    • Locating Web Elements
    • Running the Test Script
    • Writing Your First Selenium Test Script
    • Getting Started with Selenium Automation Testing
    • Setting Up the Environment
    • How can you monitor the Quality Assurance Audit?
    • Leveraging LambdaTest with Appium 2.0
    • Appium 2.0 Plugins ListAppium 2.0 Plugins
    • Touch Actions and Multi-Touch Actions
    • Changes in Drivers and Classes
    • Appium Inspector
    • Capabilities in Appium 2.0
    • Appium 2.0 Driver ListAppium 2.0 Driver Installation & Management
    CyberLink Multimedia Software

    Back to Top

    Links

    • Contact
    • Privacy Policy
    • Cookie Policy

    www.TestingDocs.com