Subtests
Defining subtests
In a test class, one can simply define subtests like class methods.
@Test('Subtest Example')
export class Example {
constructor(private desktop: DesktopTarantulaAPI, private mobile: MobileTarantulaAPI) {
console.log(this.mobile.shake(500));
console.log(this.desktop.minimize());
}
async SubtestPlaywright()
{
const browser = await framework.chromium.launch({ headless: true });
const page = await browser.newPage();
await page.goto('https://www.example.com/');
console.log(await page.title());
await browser.close();
}
async SubtestSelenum()
{
const driver = await new framework.Builder()
.forBrowser('chrome')
.build();
await driver.get('https://www.example.com/');
console.log(await driver.getTitle());
await driver.quit();
}
}
This particular example constructs two subtests based on whether someone wants to use Playwright
or Selenium
as their framework of choice.
Running subtests
Running subtests is as easy as calling the methods of an instance of the test class.
let ExampleInstance = run(Example); //Save the instance returns by the run function
ExampleInstance.SubtestPlaywright(); //Run the subtest
//Alternatively, you could call ExampleInstance.SubtestSelenum();