Careeroza
Real World Example
Smoke and Regression Suites at a Service Company
A typical retail client project at an IT services company runs two TestNG suites from the same code: a 10-minute smoke suite on every deployment to QA, and a 2-hour regression suite every night.
public class CartTest extends BaseTest {
@Test(groups = {"smoke", "regression"}, description = "TC_CART_001 add one product")
public void addOneProduct() {
open("/products/101");
click(By.id("add-to-cart"));
Assert.assertEquals(waitForText(By.id("cart-count"), "1"), "1");
}
@Test(groups = "regression", description = "TC_CART_004 remove product updates total")
public void removeProductUpdatesTotal() {
SoftAssert soft = new SoftAssert();
addProducts(101, 205);
click(By.cssSelector("[data-testid='remove-205']"));
soft.assertEquals(text(By.id("cart-count")), "1", "count");
soft.assertEquals(text(By.id("cart-total")), "₹1,299", "total");
soft.assertAll();
}
}Example
The nightly job:
mvn test -DsuiteXmlFile=regression.xml -Dbrowser=chrome -Dheadless=trueExample output
Total tests run: 312, Passes: 309, Failures: 2, Skips: 1 [ERROR] Tests run: 312, Failures: 2, Errors: 0, Skipped: 1, Time elapsed: 6894 s
Takeaway
TestNG turns scripts into an organised suite: annotations handle setup, assertions decide pass/fail, groups decide what runs when, and reports tell the team what broke.