Careeroza
Best Practices Checklist
Writing Tests
- One test checks one behaviour; the name says it:
wrongPasswordShowsError. - Arrange (data) → Act (page methods) → Assert (one main assertion, soft asserts for related fields).
- No
Thread.sleep; no implicit + explicit wait mix. - No hard-coded URLs, users or passwords in tests; use config and secrets.
- Assertions have messages:
assertEquals(actual, expected, "cart count after adding 2 items").
Running and Maintaining
- Quit the browser in
@AfterMethod(alwaysRun = true). - Screenshot, URL and page source on every failure.
- Quarantine a flaky test (a
flakygroup excluded from the gate) and open a ticket; do not delete it silently. - Track the flaky rate per test; fix the worst ten every sprint.
- Keep the UI suite small: push checks down to API and unit tests where possible.
- Review test code like production code: same Git workflow, pull requests and code style.
Tip: In interviews, "how do you handle flaky tests?" is asked almost every time. Answer with: find the root cause (wait, locator, data), fix it, and use retries only for infrastructure, with reporting of retried tests.