Found 136 Articles for TestNG

Automating Functional Tests with TestNG

Ashish Anand
Updated on 16-Aug-2023 14:48:20

103 Views

TestNG is a powerful testing framework, an enhanced version of JUnit which was in use for a long time before TestNG came into existence. NG stands for 'Next Generation'. TestNG framework provides the following features − Annotations help us organize the tests easily. Flexible test configuration. Test cases can be grouped more easily. Parallelization of tests can be achieved using TestNG. Support for data−driven testing. Inbuilt reporting. Selenium Webdriver allows to interact with webpages. It is an interface not a testing framework. To run any test or code only in selenium we must use java main method. TestNG ... Read More

How to Use Beanshell Script in TestNG?

Ashish Anand
Updated on 16-Aug-2023 13:15:53

193 Views

TestNG supports to group the test cases based on similar functionality or uses. Sometimes user has customized conditions to pick classes/methods/groups at run time based on conditions and use cases. TestNG supports simple frequently use scenarios but covering all expects are unnecessary. For Example, user may add multiple groups to single test. While running the group using syntax, TestNG runs all tests those are part of the group. It works as OR statement. Like if a test has 2 groups and only 1 is mentioned in tag it will run the test. But, when user wants ... Read More

How to check reports created by TestNG?

Ashish Anand
Updated on 16-Aug-2023 13:14:20

65 Views

TestNG allows to run the test suites from IntelliJ IDE as well as command line. When user run the testing.xml either from IDE or command line, TestNG generates a default report. It saves all reports and respective html files in Project −>test−output folder. If folder is not present, TestNG creates the folder. Enable the Report Generation While running the testing.xml from IDE, the user has to enable the default reports generation at Add Configuration −> Listeners tab. The following screenshot shows how to enable default report generation in IntelliJ. If the user wants to generate report at customized path ... Read More

How to create a TestNG file in IntelliJ IDE?

Ashish Anand
Updated on 16-Aug-2023 13:09:51

537 Views

TestNG file is a simple java class. IntelliJ supports TestNG class as simple java class. To create a TestNG class, user should create a java class first and then enter the desired TestNG annotations and respective code to execute. In this article, let’s follow the steps to create a TestNG file in IntelliJ. Approach/Algorithm to solve this problem Step 1: Go to the project where TestNG file needs to create. Step 2: Select a folder where to create a TestNG file either in src or test folder. We will create the file in src folder in this article. Step ... Read More

How to continue test execution after assertion failed in TestNG?

Ashish Anand
Updated on 16-Aug-2023 12:50:28

1K+ Views

A TestNG class can have different tests like test1, test2, test3 etc. There could be some failure while running the test suite and user may get failures in between of @Test methods. Once a test method gets failed, he wants to continue the execution so all failures can be found out at the time. By default, if a failure occurs in a @Test method, TestNG gets exit from the same @Test method and continue the execution from next @Test method. Here, the use case is to continue the execution of next line even if an assertion failed in same @Test ... Read More

How to continue execution when assertion is failed in TestNG?

Ashish Anand
Updated on 16-Aug-2023 12:46:14

598 Views

A TestNG class can have different tests like test1, test2, test3 etc. There could be some failure while running the test suite and user may get failures in between of @Test methods. Once a test method gets failed, he wants to continue the execution so all failures can be found out at the time. By default, if a failure occurs in a @Test method, TestNG gets exit from the same @Test method and continue the execution from next @Test method. Here, the use case is to continue the execution of next line even if an assertion failed in same @Test ... Read More

How do I run classes with TestNG by wildcard in testng.xml?

Ashish Anand
Updated on 16-Aug-2023 16:21:24

167 Views

testng.xml has a format as where we define what all test classes should be executed. There is no any specific way to provide regular expression in a class in . But there are work arounds those are useful to run specific @Test from a class. TestNG supports regular expression at include, exclude and package tags. Following are few ways those are handy to use regular expression in a test class run from a test suite. Mention all class names inside . And, inside the class use and . It will exclude all tests starting with name ... Read More

Difference between JUnit and TestNG

Pradeep Kumar
Updated on 25-Jul-2022 10:18:33

8K+ Views

Software Testing is an important phase in the software development lifecycle because it involves locating and identifying bugs in the programme as well as ensuring that the software is error free. Testing is analogous to "quality control" and is what guarantees quality in the development of software. Unit testing, integration testing, functional testing, performance testing, acceptance testing, etc., are just some of the many types of testing that are performed at various points throughout the process.Unit testing is carried out concurrently with the coding of a computer programme or application. In this type of testing, the smaller, more easily testable ... Read More

How does TestNG invoke a test method using multiple threads?

Ashish Anand
Updated on 09-Mar-2022 11:44:46

3K+ Views

TestNG supports multi-threading, i.e., a @Test method can be invoked multiple times in parallel. A test method should be invoked from multiple threads so that multiple invocation is also required. If we want to run a single @Test at multi-thread, it is of no use. Therefore, multi-thread is useful if a @Test method needs to be run multiple times asynchronously.Multi-threading can be achieved by using the keyword threadPoolSize = at @Test. However, to invoke a method multiple times, another keyword invocationCount =  is required. Combining these two keywords, we can achieve multi-threading. For example, @Test(threadPoolSize=5, invocationCount = 10)In this example, ... Read More

How to disable a TestNG test based on a condition?

Ashish Anand
Updated on 09-Mar-2022 11:43:08

1K+ Views

TestNG supports multiple ways to skip or ignore a @Test execution. Based on the requirement, a user can skip a complete test without executing it at all or skip a test based on a specific condition. If the condition meets at the time of execution, it skips the remaining code in the test.Following are the ways to skip the @Test execution −Use the parameter enabled=false at @Test. By default, this parameter is set as True.Use throw new SkipException(String message) to skip a test.Conditional Skip – The user can have a condition check. If the condition is met, it will throw ... Read More

Previous 1 ... 6 7 8 9 10 ... 14 Next
Advertisements