You can create a new test case or suit by extending TestNGTestCase. More specific flavor for web services is WSTestCase and for web and mobile is WebDriverTestCase. Now you can create test same as in TestNG. If you are new to TestNG, here is the documentation.

Meta-data

QAF allows you to add meta-data for test case.

  • You can use @MetaData annotation or use your custom annotation to provide meta-data.
  • All annotations parameters will be collected as meta data. It includes annotations on test method and class annotations.
  • Meta data provided at class level will be inherited by test meta-data.

meta-data can be used for test case selection by providing meta-data filter and in listeners. To enforce certain meta-data you can specify meta-data rules.

Data-driven tests

You can create and use TestNG data provider. QAF has test data filtering and intercepting capabilities along with inbuilt external data providers support.

Grouping

Test can be grouped and can be configured to run specific group or for dependency.

Setting dependency

You can set method dependency as supported by TestNG.

Precondition and post condition

Use @before/afterTest annotation from TestNG. You can call getTestBase() to have test base object in such methods.

Examples

@MetaData("{'story':'testing for fun'}")
public class SampleTestSuite extends TestNGTestCase {
    @MetaData("{'author':'me'}")
    @Test
    public void test1() {
		//your code goes here
    }
}

On extending WebDriverTestCase following object will be available to use in your test.

getTestBase()

  • When extending WebDriverTestCase Get thread safe WebDriverTestBase Instance that provides webdriver object.

getDriver()

Provides a thread safe webdriver object same as getTestBase().getDriver().

context

Instance of ITestContext, test context which contains all the information for a given test run.

props

Instance of PropertyUtil, can be used to read property value from any of the properties file.

Below are example for web/mobile test case:

@MetaData("{'story':'testing for fun'}")
public class SampleTestSuite extends WebDriverTestCase {
    @MetaData("{'author':'me'}")
    @Test
    public void test1() {
        getDriver().get("/");
        // QAFWebElement fname = getDriver().findElement("fname locator");
        QAFWebElement fname = new QAFExtendedWebElement("fname locator");
        fname.verifyText(StringMatcher.exactIgnoringCase("expected text"));
    }
}

Using Test Page in Test case

@MetaData("{'story':'testing for fun'}")
public class SampleTestSuite extends WebDriverTestCase {
    
    @MetaData("{'author':'me'}")
    @Test
    public void test1() {
        MyTestPage page = new MyTestPage();
        page.launchPage(null);
        page.getFname().verifyText("expected text");
    }
}