Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Articles by Ashish Anand
Page 4 of 14
How to disable HTML Reporting for TestNG with Maven?
Maven is a project management and comprehension tool that provides a complete build lifecycle framework. User can automate the project's build infrastructure in almost no time as Maven uses a standard directory layout and a default build lifecycle. In case of multiple environments, Maven can set−up the way to work as per standards in a very short time. As most of the project setups are simple and reusable, Maven makes life easy while creating reports, checks, build and testing automation setups. Maven provides developers ways to manage the following: Builds Documentation Reporting Dependencies SCMs Releases Distribution Mailing list ...
Read MoreAutomating Functional Tests with TestNG
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 MoreHow to Use Beanshell Script in TestNG?
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 MoreHow to continue execution when assertion is failed in TestNG?
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 MoreHow to get the result status from TestNG in @AfterMethod?
TestNG supports native dependency injection. It allows to declare additional parameters in methods. At the runtime, TestNG automatically fills these parameters with the right values. Here is a list of some native dependencies in TestNG:ITestContextXmlTestMethodITestResultYou can use these dependencies to get the execution status of a test in TestNG.Usually, @AfterMethod supports all these native dependencies and the test status could be either Success, Failure or Skip.TestNG supports the following test status that can be retrieved by calling the function at the right place.org.testng.ITestResultpublic static final intFAILURE2public static final intSKIP3public static final intSTARTED16public static final intSUCCESS1public static final intSUCCESS_PERCENTAGE_FAILURE4In this article, ...
Read MoreHow to make TestNG print a detailed message about a failure?
TestNG supports a lot of assertions. It has the org.testng.Assert class that extends the Java object class java.lang.object.Whenever there is a failure, a user would want to get a detailed failure report in order to perform a root cause analysis. But, sometimes the displayed failure information is not sufficient and sometimes the user is supplied with the same type of failure information repeated every time. These kinds of issues can be handled in TestNG using the keyword verbose ="".TestNG supports verbose and allows the user to pass a value based on the extent of failure information they want to see. ...
Read MoreHow to execute a single test from a large testing suite using TestNG.xml?
testNG.xml is very flexible and it can work as a harness file to execute the test cases. It keeps the development and execution separate from each other. A user can develop "N" number of test cases in testNG but can run a limited number of test methods based on the configuration in testNG.xml.In this article, let's see how to run only one test method from a large TestNG suite.To run only one test method, we will use the 'include' keyword from TestNG. In testNG.xml, first we will define the class name where the method is present and after that mention ...
Read MoreHow to turn off TestNG's default reporters programmatically?
TestNG allows to run the test suites from IntelliJ IDE as well as from the command line. When user runs the testNG.xml either from an IDE or the command line, TestNG generates a default report. It saves all the reports and respective HTML files in the Project->test-output folder. If this folder does not exist, then TestNG creates one.To disable the default reports programmatically, TestNG should be run through the command line (cmd).Following are the prerequisites to run the test suites from the command line −testNG.xml file should be created to define the test suites and testing classes to execute.All the ...
Read MoreHow to use TestNG SkipException?
TestNG supports multiple ways to skip or ignore a @Test execution. Based on 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 a @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 SkipException ...
Read MoreHow to assert that two Lists are equal with TestNG?
TestNG supports a lot of assertions. It has the org.testng.Assert class, which extends the Java object class java.lang.object.To compare two lists specifically, TestNG's Assert class has a method known as assertEquals(Object actual, Object expected) and there is an extended version of this method with customized message as assertEquals(Object actual, Object expected, String message).This method returns True if −both the objects are Lists, both the lists are of same size, andif the elements of the lists are in the same order.If any of these conditions are not True, it will return False.In this article, we will discuss how to compare two ...
Read More