How to skip a test method in TestNG?

At times we have a scenario, for certain methods our code is not yet complete and those test methods will be marked as fail during the execution, if we execute it with other methods.

Problem Statement :

Suppose there are 100 test methods to be executed out of which 20 test methods failed and we are not sure the failures are due to incomplete code or real defects from the AUT(Application under Test)

Solution : TestNG has provided an option to skip or bypass the incomplete test methods.


OUTPUT :

TestNG-Without-Ignore-Method

In the above example testMethod2,testMethod4 are not completed yet. Hence if we execute with these two methods, it will be marked as failed. TestNG has provided an option to choose which methods to execute by giving @Test(enabled=true) and to skip the methods we can give @Test(enabled=false) method.

Example 2 :

Leave a Comment

Your email address will not be published. Required fields are marked *