TestNG

Ace your homework & exams now with Quizwiz!

What is Hard Assert in TestNG?

Hard Assert throws an AssertException immediately when an assert statement fails and test suite continues with next @Test

How to execute the same test multiple times?

Use invocationCount with @Test method itself. @Test(invocationCount=10) // This method will we executed 10 times

What is the use of @Listener annotation in TestNG?

-TestNG listeners are used to configure reports and logging. - You can capture screenshot when there is a test failure. -One of the most widely used listeners in testNG is ITestListener interface. -It has methods like onTestStart, onTestSuccess, onTestFailure, onTestSkipped etc.

What are the advantages of TestNG?

-TestNG provides PARALLEL EXECUTION of test methods - It allows to define DEPENDENCY of one test method over other method - It allows to assign PRIORITY to test methods - It allows GROUPING of test methods into test groups - It has support for PARAMETERIZING test cases using @Parameters annotation - It allows DATA DRIVEN testing using @DataProvider annotation - It has different ASSERTIONS that helps in checking the expected and actual results - Detailed (HTML) REPORTING

What are the annotations available in TestNG?

@BeforeTest @AfterTest @BeforeClass @AfterClass @BeforeMethod @AfterMethod @BeforeSuite @AfterSuite @BeforeGroups @AfterGroups @Test

What is @Factory annotation?

@Factory: A factory will execute all the test methods present inside a test class using a separate instance of the respective class with different set of data.

What is @DataProvider annotation?

A test method that uses DataProvider will be executed the specific methods multiple number of times based on the data provided by the DataProvider

How to exclude a particular test method from a test case execution?

By adding the EXCLUDE tag in the testng.xml classes> <class name="TestCaseName"> <methods> <exclude name="TestMethodNameToExclude"/> </methods> </class> </classes>

How to skip a @Test method from execution in TestNG?

By using throw new SkipException("skipping test")

How can we create data driven framework using TestNG?

Data-driven concept is achieved by @DataProvider annotation in TestNG.

What is Soft Assert in TestNG?

Soft Assert collects errors during @Test. Soft Assert does not throw an exception when an assert fails and would continue with the next step after the assert statement.

How TestNG allows to state dependencies?

TestNG allows two ways to declare the dependencies. Using attributes dependsOnMethods @Test(dependsOnMethods = {"testCase2"}) public void testCase1(){ System.out.println("Test Case 1"); ------------------------------------------------------------ Using attributes dependsOnGroups @Test(dependsOnGroups= {"ui"})

How to run a group of test cases using TestNG?

TestNG allows you to perform groupings of test methods using "groups" @Test (groups = { "smokeTest", "RegressionTest" })

What is TestNG?

TestNG is a testing framework for the Java programming language created by Cédric Beust and inspired by JUnit and NUnit.

Why is the reporter class used in TestNG?

The reporter class in TestNG logs the tester defined messages into the reports generated by TestNG. These logged messages then print into the reports, which we can share with the team.

How to disable a Test case in TestNG

To disable the test case we use the parameter enabled = false to the @Test annotation @Test(enabled = false)

How to Ignore a test case in TestNG?

To ignore the test case we use the parameter enabled = false to the @Test annotation. @Test(enabled = false)

How to run test cases in parallel using TestNG?

Use "parallel" attribute in testng.xml to accomplish parallel test execution in TestNG. <suite name = "Smoke Test" parallel="methods">

How is exception handling done in TestNG?

We carry out Exception handling in TestNG by defining the exception at the @Test annotation level. If we proceed in such a manner, the test case will not fail even after raising an exception. @Test(expectedException = numberFormatException.class)

How to set test case priority in TestNG?

We use priority attribute to the @Test annotations. In case priority is not set then the test scripts execute in alphabetical order. (default priority is 0) -@Test(priority=0) public void testCase1() { system.out.println("Test Case 1"); } @Test(priority=1) public void testCase2() { system.out.println("Test Case 2");}


Related study sets

Imaging - CT, Questions -- Image Production-- (CT Boot camp) -- Image Post-Processing, Imaging: CT, CT Imaging Procedures Board Review

View Set

Business Law Chapter 21: "Warranties"

View Set

AMD 165 Facial Attractiveness QUIZ 11

View Set

Maternity And pediatrics Chapter 25 Growth and development of newborn and infant

View Set