{"id":1761,"date":"2022-01-19T05:47:50","date_gmt":"2022-01-19T05:47:50","guid":{"rendered":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/2022\/01\/19\/testng-interview-questions\/"},"modified":"2022-01-19T05:47:50","modified_gmt":"2022-01-19T05:47:50","slug":"testng-interview-questions","status":"publish","type":"post","link":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/2022\/01\/19\/testng-interview-questions\/","title":{"rendered":"TestNG Interview Questions"},"content":{"rendered":"<p><html><body><\/p>\n<section class=\"tcb-post-content tcb-shortcode thrv_wrapper\" data-css=\"tve-u-16ec5d248bb\">\n<div class=\"tve_flt tcb-style-wrap\" id=\"tve_flt\">\n<div class=\"tve_shortcode_editor tar-main-content\" data-post-id=\"1761\" id=\"tve_editor\">\n<div class=\"thrv_wrapper tve-toc tve-elem-scroll tve-toc-expandable tcb-local-vars-root\" data-animation=\"slide\" data-animation-speed=\"fast\" data-bullet-style='{\"0\":\"tve-u-61e7a606b05563\",\"1\":\"tve-u-61e7a606b05570\",\"2\":\"tve-u-61e7a606b05580\"}' data-columns=\"1\" data-columns-d=\"1\" data-css=\"tve-u-61e7a606b05557\" data-ct=\"toc-60671\" data-ct-name=\"Table of Contents 03\" data-element-name=\"Table of Contents\" data-headers=\"h1,h3,h5\" data-heading-style='{\"0\":\"tve-u-61e7a606b05483\",\"1\":\"tve-u-61e7a606b05532\",\"2\":\"tve-u-61e7a606b05543\"}' data-highlight=\"section\" data-number-style='{\"0\":\"tve-u-61e7a606b05592\",\"1\":\"tve-u-61e7a606b055b7\",\"2\":\"tve-u-61e7a606b055c5\"}' data-numbering=\"basic\" data-state-default=\"expanded\" data-state-default-m=\"collapsed\" data-transition=\"fade\" style=\"\">\n<div class=\"thrive-colors-palette-config\" style=\"display: none !important\"><\/div>\n<div class=\"tve-toc-divider\" style=\"position: absolute; width: 0; height: 0; overflow: hidden;\">\n<div class=\"thrv_wrapper thrv-divider tve-vert-divider\" data-color-d=\"rgba(0, 0, 0, 0)\" data-css=\"tve-u-61e7a606b055d3\" data-style=\"tve_sep-1\" data-thickness-d=\"1\">\n<hr class=\"tve_sep tve_sep-1\" style=\"\"\/><\/div>\n<\/div>\n<p><svg class=\"toc-icons\" style=\"position: absolute; width: 0; height: 0; overflow: hidden;\" version=\"1.1\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\"><symbol data-id=\"icon-circle-outlined\" id=\"toc-bullet-0\" viewbox=\"0 0 512 512\"><path d=\"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm0 448c-110.5 0-200-89.5-200-200S145.5 56 256 56s200 89.5 200 200-89.5 200-200 200z\"><\/path><\/symbol><symbol data-id=\"icon-circle-outlined\" id=\"toc-bullet-1\" viewbox=\"0 0 512 512\"><path d=\"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm0 448c-110.5 0-200-89.5-200-200S145.5 56 256 56s200 89.5 200 200-89.5 200-200 200z\"><\/path><\/symbol><symbol data-id=\"icon-circle-outlined\" id=\"toc-bullet-2\" viewbox=\"0 0 512 512\"><path d=\"M256 8C119 8 8 119 8 256s111 248 248 248 248-111 248-248S393 8 256 8zm0 448c-110.5 0-200-89.5-200-200S145.5 56 256 56s200 89.5 200 200-89.5 200-200 200z\"><\/path><\/symbol><\/svg><\/p>\n<div class=\"tve-content-box-background\" data-css=\"tve-u-61e7a606b055e1\" style=\"\"><\/div>\n<div class=\"thrv_wrapper tve-toc-title show-icon tcb-icon-display tve-no-dropzone tve-prevent-content-edit\" data-css=\"tve-u-61e7a606b055f9\" style=\"\">\n<div class=\"tve-content-box-background\"><\/div>\n<div class=\"tve-cb\" style=\"\">\n<div class=\"tve-toc-title-icon\" data-icon-code=\"icon-arrow-circle-down-solid\" style=\"\"><svg class=\"tcb-icon\" data-id=\"icon-arrow-circle-down-solid\" data-name=\"\" viewbox=\"0 0 512 512\"><path d=\"M504 256c0 137-111 248-248 248S8 393 8 256 119 8 256 8s248 111 248 248zm-143.6-28.9L288 302.6V120c0-13.3-10.7-24-24-24h-16c-13.3 0-24 10.7-24 24v182.6l-72.4-75.5c-9.3-9.7-24.8-9.9-34.3-.4l-10.9 11c-9.4 9.4-9.4 24.6 0 33.9L239 404.3c9.4 9.4 24.6 9.4 33.9 0l132.7-132.7c9.4-9.4 9.4-24.6 0-33.9l-10.9-11c-9.5-9.5-25-9.3-34.3.4z\"><\/path><\/svg><\/div>\n<div class=\"thrv_wrapper thrv_text_element tve_no_icons\">\n<div class=\"tcb-plain-text\" style=\"\">Table of Contents<\/div>\n<\/p><\/div>\n<\/div>\n<\/div>\n<div class=\"tve-cb tve-toc-content tve-prevent-content-edit\" style=\"\">\n<div class=\"thrv_wrapper tve-toc-list tcb-no-delete tcb-no-save tcb-no-clone tve-no-dropzone\" data-css=\"tve-u-61e7a606b05603\" style=\"\">\n<div class=\"tve-content-box-background\"><\/div>\n<div class=\"tve-cb\" style=\"\">\n<div class=\"tve_ct_content tve_clearfix\" style=\"\">\n<div class=\"ct_column\">\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-61e7a606b05532\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1638970939482\" jump-animation=\"smooth\">1. What is TestNG? <\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-61e7a606b05532\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1638970939483\" jump-animation=\"smooth\">2. Mention some of the Advantages of TestNG?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-61e7a606b05532\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1638970939484\" jump-animation=\"smooth\">3. Explain the difference between Test and Test Suite in TestNG.<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-61e7a606b05532\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1638970939485\" jump-animation=\"smooth\">4. Why should we use TestNG in Selenium Framework?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-61e7a606b05532\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1638970939486\" jump-animation=\"smooth\">5. How to add TestNG maven dependency in POM.xml?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-61e7a606b05532\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1638970939487\" jump-animation=\"smooth\">6. What is TestNG.XML File?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-61e7a606b05532\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1638970939488\" jump-animation=\"smooth\">7. What is annotation in TestNG?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-61e7a606b05532\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1638970939489\" jump-animation=\"smooth\">8. List some of the most common annotations used in TestNG.<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-61e7a606b05532\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1642525980189\" jump-animation=\"smooth\">9. What are PreCondition, Test, and PostCondition Annotations in TestNG?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-61e7a606b05532\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1638970939491\" jump-animation=\"smooth\">10. What is parameterization in TestNG?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-61e7a606b05532\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1638970939492\" jump-animation=\"smooth\">11. What are the Priorities in TestNG?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-61e7a606b05532\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1638970939493\" jump-animation=\"smooth\">12. How to Define Grouping in TestNG?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-61e7a606b05532\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1638970939494\" jump-animation=\"smooth\">13. How can we exclude a group in TestNG?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-61e7a606b05532\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1638970939495\" jump-animation=\"smooth\">14. What are assertions in TestNG?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-61e7a606b05532\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1638970939496\" jump-animation=\"smooth\">15. List down common Assertions used in TestNG.<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-61e7a606b05532\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1638970939498\" jump-animation=\"smooth\">16. Can you explain about handling dependent test Execution in TestNG?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-61e7a606b05532\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1638970939499\" jump-animation=\"smooth\">17. How to handle Parallel execution in TestNG?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-61e7a606b05532\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1638970939500\" jump-animation=\"smooth\">18. How to Define TimeOut in TestNG?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-61e7a606b05532\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1638970939501\" jump-animation=\"smooth\">19. What is TestNG Listners?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-61e7a606b05532\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1638970939502\" jump-animation=\"smooth\">20. Tell me about Data Providers in TestNG.<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-61e7a606b05532\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1638970939503\" jump-animation=\"smooth\">21. How Factory Different from DataProvides?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-61e7a606b05532\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1638970939504\" jump-animation=\"smooth\">22. Name the Interface which can be used to retry failed tests?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-61e7a606b05532\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1638970939505\" jump-animation=\"smooth\">23. What is the difference between TestNG and Junit?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-61e7a606b05532\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1638970939506\" jump-animation=\"smooth\">24. What is expectedExceptions Attribute in TestNG?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-61e7a606b05532\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1641829942311\" jump-animation=\"smooth\">25. How to disable a test in TestNG? Or How to skip tests in TestNG?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-61e7a606b05532\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1642513700419\" jump-animation=\"smooth\">26. What is Inclusion &amp; Exclusion Groups in TestNG?<\/a><\/div>\n<div class=\"thrv_wrapper tve-toc-heading tve-toc-heading-level1 tve_no_icons\" data-css=\"tve-u-61e7a606b05532\" data-element-name=\"Heading Level 2\" data-tag=\"H3\"><a class=\"tve-toc-anchor tve-jump-scroll\" href=\"#t-1641829942312\" jump-animation=\"smooth\">27. What is the invocation count in TestNG?<\/a><\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv-divider tve-vert-divider\" data-color-d=\"rgba(0, 0, 0, 0)\" data-css=\"tve-u-61e7a606b055d3\" data-style=\"tve_sep-1\" data-thickness-d=\"1\">\n<hr class=\"tve_sep tve_sep-1\" style=\"\"\/><\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\">\n<h3 class=\"\" data-alt-text=\"1. What is TestNG? \" id=\"t-1638970939482\"><b>\u00a01. <b><b><strong>What is TestNG<\/strong><\/b>?\u00a0<\/b><\/b><\/h3>\n<p>TestNG is an automation testing framework. TestNG is designed based on JUnit however many disadvantages of JUnit are addressed which makes TestNG unique and easy for an end to end Testing.<\/p>\n<div class=\"code-block code-block-2\" style=\"margin: 8px auto; text-align: center; display: block; clear: both;\">\n<p><!-- horizontal responsive 2 --><br \/>\n<ins class=\"adsbygoogle\" data-ad-client=\"ca-pub-3231318496783163\" data-ad-format=\"auto\" data-ad-slot=\"2788468763\" data-full-width-responsive=\"true\" style=\"display:block\"><\/ins>\n<\/div>\n<h3 class=\"\" data-alt-text=\"2. Mention some of the Advantages of TestNG?\" id=\"t-1638970939483\"><b>2. <b><b><strong>Mention some of the Advantages of TestNG<\/strong><\/b>?<\/b><\/b><\/h3>\n<ul>\n<li>Easy to group the test cases<\/li>\n<li>Easy to Configure multi-browser testing<\/li>\n<li>Easy to integrate with other frameworks such as Maven, Jenkins<\/li>\n<li>Comes with built-in HTML reports<\/li>\n<li>Allows to prioritize test cases<\/li>\n<li>Provides the option to parameterize test cases<\/li>\n<li>Provides the option to perform Data-driven testing<\/li>\n<li>\u00a0Easy to implement assertions<\/li>\n<\/ul>\n<h3 class=\"\" data-alt-text=\"3. Explain the difference between Test and Test Suite in TestNG.\" id=\"t-1638970939484\"><b>3.\u00a0<b><b><strong>Explain the difference between Test and Test Suite in TestNG.<\/strong><\/b><\/b><\/b><\/h3>\n<ul>\n<li>TestNG <strong>Test<\/strong> is a single test file or test case.<\/li>\n<li>TestNG <strong>Test Suite<\/strong> is a collection of tests that can be configured in TestNG using .xml file.<\/li>\n<li>A <strong>suite<\/strong> is represented by one XML file. It can contain one or more tests and is defined by the &lt;suite&gt; tag.<\/li>\n<li>A <strong>test<\/strong> is represented by &lt;test&gt; and can contain one or more TestNG classes.<\/li>\n<li>A <strong>TestNG<\/strong> class is a Java class that contains at least one TestNG annotation. It is represented by the &lt;class&gt; tag and can contain one or more test methods.<\/li>\n<li>A <strong>test method<\/strong> is a Java method annotated by @Test in your source.<\/li>\n<li>testng.xml example<\/li>\n<\/ul>\n<p>&lt; &lt;suite name = &#8220;Suite Name&#8221;&gt;<\/p>\n<p>\u00a0\u00a0 &lt;test name = &#8220;Test Name&#8221;&gt;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;classes&gt;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;class name = &#8220;Test Class Name&#8221; \/&gt;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;\/classes&gt;<\/p>\n<p>\u00a0\u00a0 &lt;\/test&gt;<\/p>\n<p>&lt;\/suite&gt;<\/p>\n<p><b> <\/b><\/p>\n<h3 class=\"\" data-alt-text=\"4. Why should we use TestNG in Selenium Framework?\" id=\"t-1638970939485\"><b>4. <b><b><strong>Why should we use TestNG in Selenium Framework?<\/strong><\/b><\/b><\/b><\/h3>\n<p>Selenium provides API to simulate browser actions, it doesn\u2019t provide assertions, reporters, and execution configuration. Using Selenium with TestNG makes complete Automation Framework.<\/p>\n<\/div>\n<div class=\"thrv_wrapper thrv_text_element\" data-css=\"tve-u-61e7a606b05615\" style=\"border: 1px solid rgb(0, 0, 0) !important;\">\n<h3 class=\"\" data-alt-text=\"5. How to add TestNG maven dependency in POM.xml?\" id=\"t-1638970939486\"><b>5. <b><b><strong>How to add TestNG maven dependency in POM.xml?<\/strong><\/b><\/b><\/b><\/h3>\n<p>Open pom.XML in your maven project, you need to simply add the below entries to POM.xml file.<\/p>\n<p>\u00a0&lt;dependency&gt;<\/p>\n<p>\u00a0 &lt;groupId&gt;org.testng&lt;\/groupId&gt;<\/p>\n<p>\u00a0 &lt;artifactId&gt;testng&lt;\/artifactId&gt;<\/p>\n<p>\u00a0 &lt;version&gt;6.8&lt;\/version&gt;<\/p>\n<p>\u00a0 &lt;scope&gt;test&lt;\/scope&gt;<\/p>\n<p>&lt;\/dependency&gt;<\/p>\n<h3 class=\"\" data-alt-text=\"6. What is TestNG.XML File?\" id=\"t-1638970939487\">6. <b><b><strong>What is TestNG.XML File<\/strong><\/b>?<\/b><\/h3>\n<ul>\n<li>Testing.xml file helps us to configure our test execution behaviour. Such as.<\/li>\n<li>Running Multiple Tests<\/li>\n<li>Include and Exclude Test cases<\/li>\n<li>Adding Dependancies<\/li>\n<li>Parameterization of Test cases<\/li>\n<li>\u00a0Parallel Execution<\/li>\n<\/ul>\n<h3 class=\"\" data-alt-text=\"7. What is annotation in TestNG?\" id=\"t-1638970939488\"><b>7. <b><b><strong>What is annotation in TestNG<\/strong><\/b>?<\/b><\/b><\/h3>\n<p>The TestNG annotations are used to control the flow of execution in test script. TestNG annotations are used in combination with methods or classes.<b> <\/b><\/p>\n<h3 class=\"\" data-alt-text=\"8. List some of the most common annotations used in TestNG.\" id=\"t-1638970939489\"><b>8. <b><b><strong>List some of the most common annotations used in TestNG.<\/strong><\/b><\/b><\/b><\/h3>\n<table border=\"1\" cellpadding=\"0\" cellspacing=\"0\">\n<tbody>\n<tr>\n<td valign=\"top\" width=\"112\">\n<ul>\n<li><strong>Annotations<\/strong><\/li>\n<\/ul>\n<\/td>\n<td valign=\"top\" width=\"441\">\n<ul>\n<li><strong>Description<\/strong><\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"112\">\n<ul>\n<li>@BeforeSuite<\/li>\n<\/ul>\n<\/td>\n<td valign=\"top\" width=\"441\">\n<ul>\n<li>The @BeforeSuite method in TestNG runs before the execution of all other test methods.<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"112\">\n<ul>\n<li>@AfterSuite<\/li>\n<\/ul>\n<\/td>\n<td valign=\"top\" width=\"441\">\n<ul>\n<li>The @AfterSuite method in TestNG runs after the execution of all other test methods.<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"112\">\n<ul>\n<li>@BeforeTest<\/li>\n<\/ul>\n<\/td>\n<td valign=\"top\" width=\"441\">\n<ul>\n<li>The @BeforeTest method in TestNG runs before the execution of all the test methods that are inside that folder.<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"112\">\n<ul>\n<li>@AfterTest<\/li>\n<\/ul>\n<\/td>\n<td valign=\"top\" width=\"441\">\n<ul>\n<li>The @AfterTest method in TestNG executes after the execution of all the test methods that are inside that folder.<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"112\">\n<ul>\n<li>@BeforeClass<\/li>\n<\/ul>\n<\/td>\n<td valign=\"top\" width=\"441\">\n<ul>\n<li>The @BeforeClass method in TestNG will run before the first method invokes the current class.<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"112\">\n<ul>\n<li>@AfterClass<\/li>\n<\/ul>\n<\/td>\n<td valign=\"top\" width=\"441\">\n<ul>\n<li>The @AfterClass method in TestNG will execute after all the test methods of the current class execute.<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"112\">\n<ul>\n<li>@BeforeMethod<\/li>\n<\/ul>\n<\/td>\n<td valign=\"top\" width=\"441\">\n<ul>\n<li>The @BeforeMethod method in TestNG will execute before each test method.<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"112\">\n<ul>\n<li>@AfterMethod<\/li>\n<\/ul>\n<\/td>\n<td valign=\"top\" width=\"441\">\n<ul>\n<li>The @AfterMethod method in TestNG will run after each test method is executed.<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"112\">\n<ul>\n<li>@BeforeGroups<\/li>\n<\/ul>\n<\/td>\n<td valign=\"top\" width=\"441\">\n<ul>\n<li>The @BeforeGroups method in TestNG runs before the test cases of that group are executed. It executes just once.<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<tr>\n<td valign=\"top\" width=\"112\">\n<ul>\n<li>@AfterGroups<\/li>\n<\/ul>\n<\/td>\n<td valign=\"top\" width=\"441\">\n<ul>\n<li>The @AfterGroups method in TestNG runs after the test cases of that group are executed. It executes only once.<\/li>\n<\/ul>\n<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3 class=\"\" data-alt-text=\"9. What are PreCondition, Test, and PostCondition Annotations in TestNG?\" id=\"t-1642525980189\"><b>9. <\/b><b><b><strong>What are PreCondition, Test, and PostCondition Annotations in TestNG?<\/strong><\/b><\/b><\/h3>\n<ul>\n<li><strong>Precondition annotations<\/strong> are those annotations of TestNG that are executed before the execution of test methods The Precondition annotations are @BeforeSuite, @BeforeClass, @BeforeTest, @BeforeMethod<\/li>\n<li><strong>Test annotation<\/strong> Methods annotated with @Test are called test methods which serve as a unit test<\/li>\n<li><strong>Postcondition annotations<\/strong> are those annotations that are executed after the execution of all the test methods. The postcondition annotation can be @AfterSuite, @AfterClass, @AfterTest, @AfterMethod.<b> <\/b><\/li>\n<\/ul>\n<h3 class=\"\" data-alt-text=\"10. What is parameterization in TestNG?\" id=\"t-1638970939491\"><b>10. <b><b><strong>What is parameterization in TestNG<\/strong><\/b>?<\/b><\/b><\/h3>\n<ul>\n<li>Parameterized tests allow the user to run the same test with multiple times but using different values.<\/li>\n<li><strong>Example:<\/strong><\/li>\n<li><strong>Test Script<\/strong><\/li>\n<\/ul>\n<p>public class ParameterizedTest {<\/p>\n<p>\u00a0\u00a0 @Test<\/p>\n<p>\u00a0\u00a0 @Parameters(&#8220;fruit&#8221;)<\/p>\n<p>\u00a0\u00a0 public void parameterTest(String fruit) {<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(&#8220;Parameterized value is : &#8221; + fruit);<\/p>\n<p>\u00a0\u00a0 }<\/p>\n<p>}<\/p>\n<ul>\n<li><strong>testng.xml file<\/strong><\/li>\n<\/ul>\n<p>&lt;suite name = &#8220;MySuite&#8221;&gt;<\/p>\n<p>\u00a0\u00a0 &lt;test name = &#8220;Mytest&#8221;&gt;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;parameter name = &#8220;fruit&#8221; value=&#8221;apple&#8221;\/&gt;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;classes&gt;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;class name = &#8220;ParameterizedTest&#8221; \/&gt;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;\/classes&gt;<\/p>\n<p>\u00a0\u00a0 &lt;\/test&gt;<\/p>\n<p>&lt;\/suite&gt;<\/p>\n<h3 class=\"\" data-alt-text=\"11. What are the Priorities in TestNG?\" id=\"t-1638970939492\"><b>11. <b><b><strong>What are the Priorities in TestNG<\/strong>?<\/b><\/b><\/b><\/h3>\n<p>Prioritization in TestNG provides execution sequence to the methods so that they can run on order. One after the other in the specified format.<\/p>\n<p>@Test (priority = 0)<\/p>\n<p>public void myMethod1(){<\/p>\n<p>\u00a0\u00a0 \/\/test code<\/p>\n<p>}<\/p>\n<p>@Test (priority = 10)<\/p>\n<p>public void myMethod2(){<\/p>\n<p>\u00a0\u00a0 \/\/test code<\/p>\n<p>}<\/p>\n<h3 class=\"\" data-alt-text=\"12. How to Define Grouping in TestNG?\" id=\"t-1638970939493\"><b>12. <b><b><strong>How to Define Grouping in TestNG<\/strong><\/b>?<\/b><\/b><\/h3>\n<ul>\n<li>Grouping in TestNG lets you group multiple test cases in named groups. Once you define the group you can run single or multiple groups.<\/li>\n<li><strong>Example<\/strong><\/li>\n<li>Test Script<\/li>\n<\/ul>\n<p>public class Test<\/p>\n<p>{<\/p>\n<p>\u00a0 @Test(groups = { &#8220;group1&#8221;, &#8220;group2&#8221; })<\/p>\n<p>\u00a0 public void method1()<\/p>\n<p>\u00a0 {<\/p>\n<p>\u00a0\u00a0\u00a0 \/\/Code<\/p>\n<p>\u00a0 }<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0 @Test(groups = {&#8220;group2&#8221;} )<\/p>\n<p>\u00a0 public void method2()<\/p>\n<p>\u00a0 {<\/p>\n<p>\u00a0\u00a0\u00a0 \/\/Code<\/p>\n<p>\u00a0 }<\/p>\n<p>\u00a0<\/p>\n<p>\u00a0 @Test(groups = {&#8220;group1&#8221;})<\/p>\n<p>\u00a0 public void method3()<\/p>\n<p>\u00a0 {<\/p>\n<p>\u00a0\u00a0\u00a0 \/\/Code<\/p>\n<p>\u00a0 }<\/p>\n<p>}<\/p>\n<ul>\n<li>testng.xml file<\/li>\n<\/ul>\n<p>&lt;suite name=&#8221;TestNG Grouping&#8221;&gt;<\/p>\n<p>\u00a0\u00a0\u00a0 &lt;test verbose=&#8221;2&#8243; preserve-order=&#8221;true&#8221;&gt;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;groups&gt;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;run&gt;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;include name = &#8220;group1&#8221;&gt;&lt;\/include&gt;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;include name = &#8220;group2&#8221;&gt;&lt;\/include&gt;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;\/run&gt;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;\/groups&gt;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;classes&gt;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;class name=&#8221;Project.Test&#8221;&gt;&lt;\/class&gt;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;\/classes&gt;<\/p>\n<p>\u00a0\u00a0\u00a0 &lt;\/test&gt;<\/p>\n<p>&lt;\/suite&gt;<\/p>\n<h3 class=\"\" data-alt-text=\"13. How can we exclude a group in TestNG?\" id=\"t-1638970939494\"><b>13. <b><b><strong>How can we exclude a group in TestNG<\/strong><\/b><\/b>?<\/b><\/h3>\n<ul>\n<li>TestNG allows us to ignore tests. This can be used using testng.xml file.<\/li>\n<li>If we want to exclude the test group with name \u201cExample\u201d we can do it like below.<\/li>\n<\/ul>\n<p>&lt;suite name=&#8221;Test Suite&#8221; &gt;<\/p>\n<p>\u00a0\u00a0 &lt;test name=&#8221;Test&#8221; &gt;<\/p>\n<p>\u00a0\u00a0 \u00a0\u00a0 &lt;groups&gt;<\/p>\n<p>\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;run&gt;<\/p>\n<p>\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;exclude name = &#8220;Example&#8221;&gt;<\/p>\n<p>\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;\/exclude&gt;<\/p>\n<p>\u00a0\u00a0 \u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;\/run&gt;<\/p>\n<p>\u00a0\u00a0 \u00a0\u00a0 &lt;\/groups&gt;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;classes&gt;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;class name=&#8221;TestClass&#8221; \/&gt;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 &lt;\/classes&gt;<\/p>\n<p>\u00a0\u00a0 &lt;\/test&gt;<\/p>\n<p>\u00a0&lt;\/suite&gt;<\/p>\n<h3 class=\"\" data-alt-text=\"14. What are assertions in TestNG?\" id=\"t-1638970939495\"><b>14. <b><b><strong>What are assertions in TestNG<\/strong><\/b>?<\/b><\/b><\/h3>\n<ul>\n<li>TestNG\u00a0 Assertions help to verify the expected result and the actual result. By verifying the result we can pass\/fail the tests.<\/li>\n<li>Syntax:<\/li>\n<li>Assert.Method(actual, expected, message)<\/li>\n<li>There are two types of Asserts in TestNG<\/li>\n<li><strong>Hard Assert in TestNG<\/strong> throws an AssertException, when an assert statement fails and the test suite continues with the next @Test method.<\/li>\n<li><strong>Soft Assert in TestNG<\/strong> does not throw an exception when an assert fails and would continue with the next step after the assert statement. However, we can collect the error logs and which can be verified later<i><\/i><\/li>\n<\/ul>\n<h3 class=\"\" data-alt-text=\"15. List down common Assertions used in TestNG.\" id=\"t-1638970939496\"><b>15. <b><b><strong>List down common Assertions used in TestNG.<\/strong><\/b><\/b><\/b><\/h3>\n<ul>\n<li>assertEqual(actual,expected,message)<\/li>\n<li>assertEquals(actual,expected,message)<\/li>\n<li>assertNotEquals(actual, expected, message);<\/li>\n<li>assertTrue(condition)<\/li>\n<li>assertTrue(condition, message)<\/li>\n<li>assertFalse(condition)<\/li>\n<li>assertFalse(condition, message)<\/li>\n<li>assertNull(object);<\/li>\n<li>assertNotNull(object);<\/li>\n<li>assertNotSame(Object actual, Object expected)<\/li>\n<li>assertSame(Object actual, Object expected)<\/li>\n<\/ul>\n<h3 class=\"\" data-alt-text=\"16. Can you explain about handling dependent test Execution in TestNG?\" id=\"t-1638970939498\"><b>16. <b><b><strong>Can you explain about handling dependent test Execution in TestNG<\/strong><\/b><\/b>?<\/b><\/h3>\n<ul>\n<li>A single or group of tests depends on one or more tests are called dependent tests.<\/li>\n<li>For example, test1 is depending test2. These scenarios can be handled in TestNg using <strong>dependsOnMethods \u00a0or dependsOnGroups <\/strong>attributes are used for handling dependencies of tests in TestNG.<\/li>\n<\/ul>\n<p>public class DependencyTest {<\/p>\n<p>\u00a0 @Test (dependsOnMethods = { &#8220;Test2&#8221; })<\/p>\n<p>\u00a0 public void Test1() {<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0 System.out.println(&#8220;Executes After Test2&#8221;);<\/p>\n<p>\u00a0 }<\/p>\n<p>\u00a0 @Test<\/p>\n<p>\u00a0 public void Test2() {<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0 \u00a0 System.out.println(&#8220;Executes First&#8221;);<\/p>\n<p>\u00a0 }<\/p>\n<p>}<\/p>\n<p><strong>Note: A similar way dependsOnGroups can be used to define the dependency for groups.<\/strong><\/p>\n<p><b> <\/b><\/p>\n<h3 class=\"\" data-alt-text=\"17. How to handle Parallel execution in TestNG?\" id=\"t-1638970939499\"><b>17. <b><b><strong>How to handle Parallel execution in TestNG?<\/strong><\/b><\/b><\/b><\/h3>\n<ul>\n<li>Parallel Testing in TestNG is a technique in which multiple tests are executed simultaneously in different threads to reduce execution time.<\/li>\n<li>The testng.xml <strong>parallel<\/strong> attribute is used for this purpose.<\/li>\n<li>TestNG allows us to execute tests parallelly at various levels.<\/li>\n<li><strong>Method:<\/strong> Runs the parallel tests on all @Test methods in TestNG<\/li>\n<li>Ex: &lt;suite name = &#8220;Parallel Test&#8221; parallel = &#8220;methods&#8221;&gt;<\/li>\n<li><strong>Test:<\/strong> All the test cases present inside the &lt;test&gt; tag will run with this value.<\/li>\n<li>Ex: &lt;suite name=&#8221;Test class Suite&#8221; parallel=&#8221;tests&#8221; thread-count=&#8221;2&#8243;&gt;<\/li>\n<li><strong>Classes:<\/strong>\u00a0 Each class will be started and executed simultaneously in different threads<\/li>\n<li>Ex: &lt;suite name=&#8221;Parallel&#8221; parallel=&#8221;classes&#8221; thread-count=&#8221;2&#8243;&gt;<\/li>\n<li><strong>Instances:<\/strong> TestNG will run all the methods in the same instance in the same thread, but two methods on two different instances will be running in different threads<\/li>\n<li>Ex: &lt;suite name = \u201cParallel Test Suite\u201d parallel = \u201cinstances\u201d thread-count = \u201c4\u201d&gt;<\/li>\n<\/ul>\n<h3 class=\"\" data-alt-text=\"18. How to Define TimeOut in TestNG?\" id=\"t-1638970939500\"><b>18. <b><b><strong>How to Define TimeOut in TestNG<\/strong><\/b>?<\/b><\/b><\/h3>\n<ul>\n<li>TestNG allows users to configure a time for a test to completely execute.<\/li>\n<li>Timeout attribute with @Test tag is used for this purpose.<\/li>\n<li>Example:<\/li>\n<\/ul>\n<p>@Test ( timeOut = 500 )<\/p>\n<p>Public void timeOutExample(){<\/p>\n<p>\/\/code<\/p>\n<p>}<\/p>\n<ul>\n<li>The timeout can also be handled using the testng.xml file.<\/li>\n<li>Example:<\/li>\n<li>&lt;suite name= &#8220;Test Suite&#8221; time-out=&#8221;500&#8243;&gt;<\/li>\n<li>&lt;test name=&#8221;Test1&#8243; verbose=&#8221;2&#8243; time-out=&#8221;300&#8243;&gt;<\/li>\n<\/ul>\n<h3 class=\"\" data-alt-text=\"19. What is TestNG Listners?\" id=\"t-1638970939501\"><b>19. <b><b><strong>What is TestNG Listners<\/strong><\/b><\/b>?<\/b><\/h3>\n<ul>\n<li>TestNG Listeners are TestNG annotations that \u201clisten\u201d to the events in a script. This helps to modify the default behavior of TestNG. If we want to take a screenshot of test failures we need to Listen to Test Failure. @Listeners annotations are used at the class level to implement listeners.<\/li>\n<li>The ITestListener is the most used TestNG interface it has a method like onTestStart, onTestSuccess, onTestFailure, onTestSkipped, etc. using this we can configure reporters and custom logging capability in TestNG.<\/li>\n<\/ul>\n<h3 class=\"\" data-alt-text=\"20. Tell me about Data Providers in TestNG.\" id=\"t-1638970939502\"><b>20. <b><b><strong>Tell me about Data Providers in TestNG.<\/strong><\/b><\/b><br \/><!--[if !supportLineBreakNewLine]--><\/b><\/h3>\n<ul>\n<li>TestNG Data Provider is a method of a class which is having annotation @DataProvider and returns an array of objects, which can be used inside our actual test.<\/li>\n<li>Example:<\/li>\n<\/ul>\n<p>public class DataProviderClass {<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0 @Test (dataProvider=&#8221;getData&#8221;)<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0 public void loginTest(String FirstName, String LastName){<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(&#8220;First Name is &#8220;+ FirstName);<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(&#8220;Last Name is &#8220;+ LastName);<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0 @DataProvider(name=&#8221;getData&#8221;)<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0 public Object[][] getData(){<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 Object [][] data = new Object [2][2];<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 data [0][0] = &#8220;FirstName1&#8221;;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 data [0][1] = &#8220;LastName1&#8221;;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 data[1][0] = &#8220;FirstName2&#8221;;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 data[1][1] = &#8220;LastName2&#8221;;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 return data;<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0 }<\/p>\n<p>}<\/p>\n<h3 class=\"\" data-alt-text=\"21. How Factory Different from DataProvides?\" id=\"t-1638970939503\">21. <b><b><strong>How Factory Different from DataProvides<\/strong>?<\/b><\/b><\/h3>\n<ul>\n<li>@DataProvider \u2013 A test method that uses @DataProvider will be executed multiple times based on the configuration. The test method will be executed using the same instance of the test class to which the test method belongs.<\/li>\n<li>@Factory \u2013 A factory will execute all the test methods present inside a test class using separate instances of the class.<\/li>\n<\/ul>\n<h3 class=\"\" data-alt-text=\"22. Name the Interface which can be used to retry failed tests?\" id=\"t-1638970939504\">22. <b><b><strong>Name the Interface which can be used to retry failed tests<\/strong>?<\/b><\/b>\u00a0 \u00a0 \u00a0 \u00a0 \u00a0<\/h3>\n<p>IRetryAnalyzer is used to retry failed tests.<\/p>\n<p>Steps to Create Retry Failed Tests<\/p>\n<ul>\n<li>Create a class to implement IRetryAnalyzer<\/li>\n<li>Create another class \u2018RetryListenerClass\u2019 by Implementing the\u2018 IAnnotationTransaformer\u2019 interface, which will use the implementation of the above class<\/li>\n<li>Add Listener to testng.xml File<\/li>\n<\/ul>\n<h3 class=\"\" data-alt-text=\"23. What is the difference between TestNG and Junit?\" id=\"t-1638970939505\">23. <b><b><strong>What is the difference between TestNG and Junit<\/strong><\/b><\/b>?<\/h3>\n<ul>\n<li>Junit is mostly focused on Unit Testing, TestNG has rich features for both Unit and end to testing.<\/li>\n<li>Generating HTML Reports is a complicated task in JUnit, TestNG provides an easy way to generate HTML reports.<\/li>\n<li>Advanced Features such as Dependency Test, Parameterization, Priority setting is sometimes a complex task or we need to follow a workaround to implement these features, TestNG comes with the default set of features to support mentioned features.<\/li>\n<\/ul>\n<h3 class=\"\" data-alt-text=\"24. What is expectedExceptions Attribute in TestNG?\" id=\"t-1638970939506\">24. <b><b><strong>What is expectedExceptions Attribute in TestNG<\/strong><\/b><\/b>?<\/h3>\n<p>If the exception thrown by the test is part of the the <strong>expectedExceptions<\/strong> attribute then the exceptions are ignored and not marked as failure.<\/p>\n<p>@Test(expectedExceptions = { IOException.class })\u00a0<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0 public void exceptionTestOne() throws Exception {<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 throw new IOException();<\/p>\n<p>\u00a0 \u00a0 \u00a0 }<\/p>\n<h3 class=\"\" data-alt-text=\"25. How to disable a test in TestNG? Or How to skip tests in TestNG?\" id=\"t-1641829942311\">25. <b><b><strong>How to disable a test in TestNG? Or How to skip tests in TestNG<\/strong><\/b><\/b>?<\/h3>\n<p>We can disable the test using enabled attribute. Setting enabled =false disables the test.<\/p>\n<p>@Test(enabled = false)<\/p>\n<p>public void Test() {<\/p>\n<p>\u00a0\u00a0 System.out.println(&#8220;Hello World&#8221;);<\/p>\n<p>}<\/p>\n<h3 class=\"\" data-alt-text=\"26. What is Inclusion &amp; Exclusion Groups in TestNG?\" id=\"t-1642513700419\">26. <b><b><strong>What is Inclusion &amp; Exclusion Groups in TestNG<\/strong><\/b><\/b>?<\/h3>\n<p>A Test Group which is included for test execution is called the Inclusion Group. A Test Group which is excluded from test execution is called Exclusion Group<\/p>\n<h3 class=\"\" data-alt-text=\"27. What is the invocation count in TestNG?\" id=\"t-1641829942312\">27. <b><b><strong>What is the invocation count in TestNG<\/strong><\/b><\/b>?<\/h3>\n<p>invocation count is an attribute, when used it executes the test a specified number of times.<\/p>\n<p>public class MultipletimesRun {<\/p>\n<p>\u00a0\u00a0\u00a0 @Test(invocationCount=5)<\/p>\n<p>\u00a0\u00a0\u00a0 public void run five times(){<\/p>\n<p>\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0\u00a0 System.out.println(&#8220;Execute 5 times&#8221;);<\/p>\n<p>\u00a0\u00a0\u00a0 }<\/p>\n<p>}<\/p>\n<ul>\n<li><strong>Author: Ganesh Hegde | <\/strong><a href=\"https:\/\/www.linkedin.com\/in\/ganeshsirsi\/\" rel=\"noopener\" target=\"_blank\"><strong>LinkedIn<\/strong><\/a><\/li>\n<li>Ganesh Hegde is an Experienced SDET\/Quality Assurance Engineer. He has expertise in Java, C#, Selenium Webdriver, TestNG, Cypress, Protractor, TestCafe, Playwright, WebdriverIO. He is also a passionate blogger and content writer.<\/li>\n<\/ul>\n<p><\/p>\n<\/div>\n<\/div>\n<\/div>\n<div class=\"tcb_flag\" style=\"display: none\"><\/div>\n<\/section>\n<p><\/body><\/html><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Table of Contents 1. What is TestNG? 2. Mention some of the Advantages of TestNG? 3. Explain the difference between Test and Test Suite in TestNG. 4. Why should we use TestNG in Selenium Framework? 5. How to add TestNG maven dependency in POM.xml? 6. What is TestNG.XML File? 7. What is annotation in TestNG? [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[4,3],"tags":[],"class_list":["post-1761","post","type-post","status-publish","format-standard","hentry","category-interview-questions","category-testng","post-wrapper","thrv_wrapper"],"_links":{"self":[{"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1761","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/comments?post=1761"}],"version-history":[{"count":0,"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/posts\/1761\/revisions"}],"wp:attachment":[{"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/media?parent=1761"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/categories?post=1761"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/rahulshettyacademy.com\/blog\/index.php\/wp-json\/wp\/v2\/tags?post=1761"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}