0% found this document useful (0 votes)
2K views3 pages

TestNG Notes

TestNG is a testing framework for Java that provides features like annotations, test grouping, parallel test execution, and data-driven testing. It has more features than JUnit and allows test configuration, dependencies between tests, and parallelization to save time. TestNG uses annotations to define test behavior and sequence, allows prioritizing tests, setting timeouts, skipping tests, parameterization, and parallel execution on a single machine or grid.

Uploaded by

Testing Career
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2K views3 pages

TestNG Notes

TestNG is a testing framework for Java that provides features like annotations, test grouping, parallel test execution, and data-driven testing. It has more features than JUnit and allows test configuration, dependencies between tests, and parallelization to save time. TestNG uses annotations to define test behavior and sequence, allows prioritizing tests, setting timeouts, skipping tests, parameterization, and parallel execution on a single machine or grid.

Uploaded by

Testing Career
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

TestNG

1.What is TestNG?

TestNG is a testing framework for Java that is used for unit testing, integration testing, and functional
testing of Java applications. It provides features such as annotations, grouping of tests, parallel test
execution, and data-driven testing.

2.Benefits of TestNG:

 TestNG provides flexible test configuration and allows to define dependencies among
test methods.
 It supports parallel test execution, which helps to save time.
 TestNG allows to group test cases and prioritize them, making it easy to execute a
specific set of tests.
 It provides better reporting options, such as HTML reports, XML reports, and email
reports.
 TestNG allows to run tests in multiple threads, which helps to speed up the execution
process.

3. Junit Vs TestNG:

 TestNG provides more features than JUnit, such as support for data-driven testing,
parallel test execution, and better reporting.
 TestNG provides annotations for defining test methods, while JUnit uses methods to
define tests.
 TestNG allows to define dependencies among test methods, which is not possible in
JUnit.
 TestNG supports grouping of test cases, while JUnit does not provide this feature.

4. Annotations: Annotations are used in TestNG to define the behavior of test methods. Some of
the commonly used annotations are:

STCM- SuiteTestClassMethod

 @Test: This annotation is used to define a test method.


 @BeforeTest: This annotation is used to define a method that runs before a test method.
 @AfterTest: This annotation is used to define a method that runs after a test method.
 @BeforeSuite: This annotation is used to define a method that runs before a test suite.
 @AfterSuite: This annotation is used to define a method that runs after a test suite.
 @BeforeClass: This annotation is used to define a method that runs before a test class.
 @AfterClass: This annotation is used to define a method that runs after a test class.
 @BeforeMethod
 @AfterMethod
Sequence of Annotations: The sequence of annotations in TestNG is as follows:

 @BeforeSuite
 @BeforeTest
 @BeforeClass
 @BeforeMethod
 @Test
 @AfterMethod
 @AfterClass
 @AfterTest
 @AfterSuite

5. Prioritize:

TestNG allows to prioritize the test methods using the priority attribute of the @Test annotation. The
methods with a lower priority value are executed first.

6. Timeout:

Timeout is used to specify the maximum time in milliseconds that a test method can take to execute. If
the test method takes longer than the specified time, it will be marked as a failed test.

7. Skip:

Skip is used to skip a test method. It is useful when a test is not ready or when it is not required to run a
test in a specific run.

8. Cross-Browser automation testing:

Cross-browser automation testing can be done in TestNG by using a Selenium WebDriver for each
browser. The browser-specific WebDriver can be initialized in the @BeforeTest method, and the test
methods can be executed in parallel using TestNG's parallel execution feature.

9. Parameterize:

TestNG allows to parameterize the test methods using the @Parameters annotation. The values for the
parameters can be provided in the testng.xml file or by using a data provider.

10. Parallel execution of automation test cases:

TestNG provides the option to execute the test methods in parallel. The parallel execution can be done
at the method level, class level, or suite level. The parallel execution can be done on the same machine
or on multiple machines using TestNG's grid

11.GIT commands:
GIT is a version control system used for software development. Some common GIT commands
are:

 git init: initializes a new repository


 git add: adds files to the staging area
 git commit: commits changes to the repository
 git push: pushes changes to a remote repository
 git pull: pulls changes from a remote repository
 git branch: creates a new branch
 git checkout: switches to a different branch
 git merge: merges changes from one branch into another

12.Jenkins:

Jenkins is a popular open-source automation server that is used to automate software builds,
tests, and deployments. It is used to build and test software projects continuously, making it
easier to detect and fix issues early in the development cycle.

13.Continuous Integration:

Continuous Integration (CI) is a software development practice where code changes are
frequently merged into a shared repository and tested automatically. The goal of CI is to catch
and fix issues as early as possible in the development cycle.

14.Tools:

TestNG is just one of many tools used for software testing. Other popular tools include
Selenium, JUnit, Cucumber, Appium, and more.

15.Framework:

A test automation framework is a set of guidelines, standards, and coding practices that are
followed to create and maintain test cases. Frameworks make it easier to design, write, and
maintain test cases, and can help ensure that testing is consistent and effective.

16.Types of Framework: There are many different types of test automation frameworks,
including:

 Keyword-driven frameworks
 Data-driven frameworks
 Hybrid frameworks
 Behavior-driven development (BDD) frameworks
 Model-based testing frameworks
 Test-driven development (TDD) frameworks
 Page Object Model (POM) frameworks
 Modular frameworks

You might also like