0

I have coded many Test Cases as Test Methods with @Test Annotation.

I have used only one class for all methods.

I want to run only 1 or 2 particular methods. And not run other methods. Please advice.

1

It can be done by using an .xml file present at the root of the project.

In that .xml file you can you use include,

To include only a particular @Test method to run like the following :

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
<suite name="Suite">
  <test name="Test">
    <classes>   
      <class name ="Full path to the Test class" />
         <methods>
            <include name="testMethodName" />
         </methods>
    </classes>
  </test> 
</suite> <!-- Suite -->
0

Are you using any framework right now? If not so it would be advisable to create a Keyword driven framework so that you can overcome above problem.

0

You can include the required test method name under the methods tag as shown below.

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE suite SYSTEM "https://testng.org/testng-1.0.dtd">
<suite name="Suite">
    <test thread-count="5" name="Test">
        <classes>
            <class name="testNG.Event">
                <methods>
                    <include name="checkOut" />
                </methods>
            </class>
        </classes>
    </test> <!-- Test -->
</suite> <!-- Suite -->

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.