Create a proper XML file to run specific tests in a class

Answered

package FrameWork;

public class SFAutomation {

public WebDriver driver;
@Test(priority = 0, enabled = true)

public void Login() {
Test something 1

}
@Test(priority = 1, enabled = true)

public void accountTab()  {
Test  something 2

}
@Test(priority = 2, enabled = true)

public void createAccount() throws InterruptedException  {
Test  something 3

}

I’m trying to run select tests from my class using an XML file rather than using the enable flag as I’m doing now. Or do I need to create separate classes for each test? I’m not sure of the XML configuration to do it.

Add Comment
  • 1 Answer(s)
    Best answer

    I founds a way to auto generate the XML then I added my tests:

    
    <?xml version="1.0" encoding="UTF-8"?>
    
    <!DOCTYPE suite SYSTEM "http://testng.org/testng-1.0.dtd">
    
    <suite name="Suite qa" parallel="none">
    
    <test name="accountTab">
    
    <classes>
    
    <class name="FrameWork.SFAutomation"/>
    
    <methods>
    
    <include name="Login"/>
    
    <include name="Login"/>
    
    <include name="createAccount"/>
    
    </methods>
    
    </classes>
    
    </test> <!-- My Test -->
    
    </suite> <!-- Suite qa -->
    
    
    Train Answered on October 15, 2014.
    Add Comment
  • Your Answer

    By posting your answer, you agree to the privacy policy and terms of service.