TestNG Notes
TestNG Notes
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- SuiteTestClassMethod
@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.
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.
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:
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