Friday, July 6, 2018

How to execute test methods in parallel in TestNG?

Executing the test cases in parallel is one of the important automation feature. TestNG framework has this feature in built, we don't need to write separate code for this. Just with simple configuration in testng.xml file we can achieve the parallel execution at different levels.

We all know that the idea of having parallel execution is to reduce the execution time, with reduced execution time we can provide early feedback then we can save our efforts and money.

In this tutorial we will learn executing the test methods (test cases) in a java class file in parallel

Wednesday, July 4, 2018

How to enable or disable/ignore test methods in TestNG?

Sometimes we will be running into the situation where we need to disable/ignore some of the test cases or test methods from the execution because of various reasons like the test is failing due to known issue, the test data is not ready for the test and etc.

@Test annotation has many attributes, 'enabled' is the attribute used for disabling a test method. If we write @Test(enabled=false) for any test method in TestNG, then it will be ignored in the execution.

By default @Test() is enabled. @Test() is equivalent to @Test(enabled=true). Let us see an example on this to understand it better.

Tuesday, July 3, 2018

How to execute multiple test suites (testng.xml files) in TestNG?

We have seen in the previous post How to execute multiple test cases in TestNG?. In this post we will see executing multiple test suites in TestNG.

Generally in our projects we will be maintaining the test scripts in different test suites, say regressionSuite.xml, smokeSuite.xml. Or we may have the test suites based on the module also say homePageSuite.xml, checkoutPageSuite.xml and etc. Using the test suites the maintenance and tracking is easy.

We know how to execute a test suite, we have discussed in the previous posts. But sometimes we need to execute more than one suite at a time, both smoke and regression suites at  a time or different modules test suites at a time, how to do that? let us see:

Java Program 5: How to reverse given string and each word of it?

Let us understand the problem with an example, suppose "Learn Core Java" is the given string then the expected output should be &...