Found 136 Articles for TestNG

How to perform data parameterization in TestNG?

Debomita Bhattacharjee
Updated on 19-Nov-2021 12:21:02

218 Views

We can perform data parameterization in TestNG. The parameterization in execution in TestNG can be done in the following ways −data parameterization with @Parameters annotation.data parameterization with @DataProvider annotation.ExampleCode Implementation of TestNG xml file with @Parameter annotation. We can pass values at runtime to the test methods by defining in the TestNG xml file.Exampleimport org.testng.annotations.Parameters; import org.testng.annotations.Test; public class TestParameter { ... Read More

How to skip a particular test method in TestNG?

Debomita Bhattacharjee
Updated on 19-Nov-2021 12:15:52

774 Views

We can skip a particular test method in TestNG. To overlook a particular test method from execution in TestNG enabled helper attribute is used. This attribute has to be set to false to overlook a test method from execution. Code Implementation of Java class file.@Test(enabled=false) public void verifyRepay(){ System.out.println("Repayment successful"); } @Test public void Login(){ System.out.println("Login is successful "); } @Test public verifyHistory(){ System.out.println ("History verification is successful"); }Here the verifyRepay() method shall be overlooked during execution.

How To Use TestNG Framework For Creating Selenium Scripts?

Debomita Bhattacharjee
Updated on 29-Jun-2021 07:43:50

209 Views

We can use the TestNG framework for creating Selenium scripts. TestNG is a testing framework built for the usage of both the developers and testers. The steps to integrate TestNG with Selenium scripts are listed below −Step1 − Click on the Help menu from Eclipse. Then click on Eclipse Marketplace.Step 2 − In the Eclipse Marketplace pop-up, input TestNG within the Find field and click on Go. Then click on Install.Step 3 − Accept the license agreement radiobutton and then click on Finish.Step 4 − Click on the Restart Now button.Step5 − Click on the File menu, then click on ... Read More

How to combine multiple groups to single Test in TestNG?

Debomita Bhattacharjee
Updated on 11-Jun-2020 12:59:31

1K+ Views

We can combine multiple groups to single Test in TestNG with the help of test group feature.ExampleTestng xml files with groups.                                                                                                           To run a group of test cases from the collection of test cases, we have to define in the testng xml file. Here the testNG xml contains multiple groups QuestionAnswer and Jobs to be associated to a single Test.Example@Test(groups={"QuestionAnswer"},{"Jobs"}) public void preparation(){    System.out.println("Preparation module is verified"); }In the Java class file the test methods with group as QuestionAnswer and Jobs are associated with the test method preparation().

What do you mean by Listeners in TestNG?

Debomita Bhattacharjee
Updated on 11-Jun-2020 12:58:14

443 Views

TestNG Listeners have the capacity to listen to a specific incident. It is basically an interface that changes the nature of the system. TestNG Listeners are used for logging purposes and creating reports.There are two Listeners in Selenium. They are listed below −TestNG Listeners.WebDriver Listeners.TestNG can be configured with the Listeners which can change the default behavior of the TestNG. TestNG Listeners are known as iTestListener (a TestNG interface). A java class implements the iTestListeners and at the same time overrides its methods. Each of these methods trigger an event.The functions of TestNG listeners are listed below.iSuiteListener − This consists ... Read More

How to achieve parallel execution in TestNG?

Debomita Bhattacharjee
Updated on 11-Jun-2020 12:54:29

562 Views

We can achieve parallel execution with the help of TestNG. There is a parallel attribute in TestNG which is used for this implementation. The parallel execution in TestNG is associated with another attribute called thread-count.The parallel attribute can have the values listed below −Methods.Classes.InstancesTestsExampleTestng xml file.                                                                           The execution will trigger in parallel mode for tests with the thread count of 5.

What do you mean by timeOut in TestNG?

Debomita Bhattacharjee
Updated on 11-Jun-2020 12:52:40

2K+ Views

The timeOut is a helper attribute in TestNG that can put an end to the execution of a test method if that method takes time beyond the timeOut duration. A timeOut time is set in milliseconds, after that the test method will be marked Failed.Example@Test public void ContactVerify(){    System.out.println("Contact validation is successful”); } @Test(timeOut = 1000) public void LandingPage(){    System.out.println("Landing page verification is successful”); } @Test public void LoanContact(){    System.out.println("Loan contact details verification is successful”); }After 1000ms, if LandingPage() execution continues , that test method will be considered as failed. The rest of the test methods will ... Read More

How to incorporate and remove test methods from execution from acollection of test cases in TestNG?

Debomita Bhattacharjee
Updated on 11-Jun-2020 12:51:12

247 Views

We can incorporate and remove test methods from execution with the help of tags in testng xml file.ExampleTestng xml file.                                                                                       The testNG xml has groups Smoke to be included and CodingModule to be excluded from the execution.Example@Test(groups={"Smoke"}) public void ContactDetails(){    System.out.println(“Contact details verification is successful”); } @Test(groups={"CodingModule"}) ... Read More

How to execute a particular test method multiple times (say 5 times) inTestNG?

Debomita Bhattacharjee
Updated on 11-Jun-2020 12:48:55

525 Views

We can execute a particular test method multiple times (say 5 times) with the help of the invocationCount helper attribute.Example@Test public void PaymentDetails(){    System.out.println("Payment details validation is successful”); } @Test(invocationCount=5) public void LoginAdmin(){    System.out.println("Login in admin is successful”); } @Test public void LeaseDetails(){    System.out.println("Lease details verification is successful”); }In the Java class file, the LoginAdmin() method with invocationCount set to 5 will result in Login in admin is a successful message to be printed five times on the console.

How will you run a prerequisite method and post condition method forevery test in TestNG?

Debomita Bhattacharjee
Updated on 11-Jun-2020 12:47:26

221 Views

We can run a prerequisite method and post condition method for every test in TestNG with the help of @BeforeMethod and @AfterMethod annotations.Example@BeforeMethod public void prerequisite(){    System.out.println("Run before every tests"); } @AfterMethod public void postcondition(){    System.out.println("Run after every tests "); } @Test public void loanPay(){    System.out.println("Loan pay is successful"); }In the Java class file, the prerequisite() method with @BeforeMethod will be executed which is known as the precondition for every test method. Then loanPay() will be executed and finally the postcondition() method with @AfterMethod will run.

Advertisements