Found 139 Articles for TestNG

How to Download the Latest TestNG Jar File?

Ashish Anand
Updated on 21-Aug-2023 12:53:44

614 Views

TestNG is an open−source automation testing framework. It can be used along with build tool such as maven, Gradle, ant and even with snapshot. However, user can separately download the TestNG jar file and configure it with the project without using build tool. In this article, we will see how to download latest TestNG jar. Download latest TestNG jar Following steps should be followed to download the latest/specific version of TestNG jar. Open the browser and navigate to https://testng.org. Once page opens, click on Download present at top. Following screenshot displays testing.org page and download button. ... Read More

How do I Run Classes with TestNG by Name and Wildcard in testng.xml?

Ashish Anand
Updated on 21-Aug-2023 12:52:17

121 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. Here, the problem statement is when a user wants to run only specific classes those are having specific format like initial name of classes should be same. For example, the user wants to run all classes whose name starts with NewTest. In this ... Read More

Why to use Selenium with TestNG?

Ashish Anand
Updated on 21-Aug-2023 12:49:53

109 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. Multiple test cases can be grouped more easily. Parallelization of tests can be achieved using TestNG. Support for data− driven testing. Inbuilt reporting as well as supported by Extent Reporting and other reporting tools. Selenium by default doesn’t generate any report. Easily configured for Cross Browser testing. TestNG framework can easily integrate ... Read More

Why does TestNG Allow Several Expected Exceptions?

Ashish Anand
Updated on 21-Aug-2023 12:45:28

89 Views

TestNG supports multiple exceptions in single @Test method. It is similar to the catch exception in Java where user can mention multiple exception class those are possible to be thrown. Ex: Syntax in catch exception is: catch(IOException | InterruptedException ex) { Similarly, syntax in TestNG is: @Test(expectedExceptions={NullPointerException.class, IllegalArgumentException.class }) public void throwsNullPointer() { throw new NullPointerException(); } One point to note that, in such scenarios, TestNG expects the one of the exceptions must be thrown from the list. If exception is different from the list or no exception, in such cases it fails the method. ... Read More

What is the Best Practice to Skip a Test in TestNG?

Ashish Anand
Updated on 21-Aug-2023 11:44:27

131 Views

TestNG supports multiple ways to skip or ignore a @Test execution. Based on requirement, user can skip a complete test without executing it at all or skip a test based on specific condition. If condition meets at the time of execution, it skips remaining code in the test. There are following 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 − User can have a condition check, if condition is met, it will throw SkipException and ... Read More

What is TestNG ERROR – Cannot find Class in Classpath?

Ashish Anand
Updated on 21-Aug-2023 11:42:34

470 Views

User may encounter Cannot find class in classpath exception while executing tests in TestNG framework. The meaning of this error is TestNG unable to find the class as mentioned in testng.xml. This can be caused because of the following reasons − In the TestNG XML, the class tag having the name attribute. User should define the class name as . format. It should not have the .java extension. In the TestNG XML, the class file is incorrect and hence unable to determine the classpath of the class. Errors within the project are present and may require a clean project. ... Read More

What is Difference Detween assertEquals() vs assertTrue() in TestNG

Ashish Anand
Updated on 21-Aug-2023 11:41:08

285 Views

TestNG supports Assertion class that is used for validation. assertTrue() and assertEquals() are supported functions of this class. assertEquals() This function is used to assert whether 2 data values are equal or not. Data types can be used to assert are String, int, Boolean etc. The user should make sure both of values are same data type otherwise it will throw the exception. Syntax is: assertEquals(actual, expected) It accepts 2 parameters − actual and expected to assert values. When given 2 data are same, assertion gets passed without any exception. However, if both of data are no same it throws ... Read More

What are Default Listeners in TestNG?

Ashish Anand
Updated on 04-Mar-2024 13:34:16

133 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. TestNG can be configured with the Listeners which can change the default behavior of the TestNG. There are several interfaces that allows to modify TestNG's behavior. These interfaces are broadly called "TestNG Listeners". Here are a few listeners: IAnnotationTransformer IAnnotationTransformer2 IHookable IInvokedMethodListener IMethodInterceptor IReporter generateReport(java.util.List xmlSuites, java.util.List suites, java.lang.String outputDirectory) - Generate a report for the given ... Read More

What are TestNG and JUnit Frameworks in Selenium?

Ashish Anand
Updated on 21-Aug-2023 11:38:42

103 Views

JUnit and TestNG are the most popular testing frameworks for Java applications or Selenium. Both frameworks are easy to use. So, when it comes to choose the testing framework for your application, it’s better to have a high−level idea of what features are present in one or the other and then take the informed decision based on your project requirements. In this article, we will discuss about JUnit and TestNG. What is TestNG Definition of TestNG as per its documentation is as follows − TestNG is a testing framework inspired from JUnit and NUnit but introducing some new functionalities that ... Read More

How to use TestNG @After Annotation?

Ashish Anand
Updated on 21-Aug-2023 11:37:06

115 Views

A TestNG class can have various @After TestNG methods. Such as: @AfterTest @AfterSuite @AfterClass @AfterMethod etc. This article will explain the order of execution of different TestNG methods. TestNG consists of following @After methods to support main @Test method. The order of execution of @After methods should be as following: Key Points in this Order are First of all, 1st @test() method is executed in above example. The AfterSuite() method executes only once. Even the methods AfterClass(), and AfterTest() methods are executed only once. AfterMethod() method executes for each test case (every time ... Read More

1 2 3 4 5 ... 14 Next
Advertisements