You maintain suites: smoke (10 min, every build) vs full regression (2 days, per release).
@Tag gives tests those labels, and Maven runs exactly the subset you name. Same triage, now executable.
@BeforeEach runs per test; @BeforeAll runs once per class — for expensive shared setup like reading a config file or preparing test data. It must be static (class-level, not instance-level — the OOP lesson's distinction earning its keep):
@BeforeAll static void once() { /* runs 1x, before everything */ } @BeforeEach void setUp() { /* runs before each @Test */ } /* ... your @Test methods ... */ @AfterEach void tearDown() { /* runs after each @Test */ } @AfterAll static void cleanup() { /* runs 1x, after everything */ }
@Test @Tag("smoke") void validLogin() { /* ... */ } @Test @Tag("regression") void sortByPriceDescending() { /* ... */ }
mvn test -Dgroups=smoke # only @Tag("smoke") mvn test -DexcludedGroups=slow # everything except @Tag("slow") mvn test -Dtest=LoginTest # one class (from the terminal lesson)
[INFO] Running LoginTest
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 ← only the smoke test ran
[INFO] BUILD SUCCESSThis is how CI stays fast: the pipeline runs -Dgroups=smoke on every commit (minutes) and the full suite nightly (hours). You'll wire exactly that in Suite 07.
@Disabled("reason") — skip a test visibly (shows as Skipped in reports). Infinitely better than commenting it out and forgetting it existed.@Order(1) + @TestMethodOrder — force execution order. Exists; avoid it. Order-dependent tests are coupled tests, and coupled tests are flaky tests.Fix: Tag strings are case-sensitive (@Tag("smoke") vs -Dgroups=Smoke won't match), and in PowerShell wrap the whole flag in quotes: mvn test "-Dgroups=smoke". A green build with 0 tests is a silent lie — always read the count.
Fix: Commented-out tests vanish from every report. @Disabled("reason") keeps it visible as Skipped: 1 in every run — a todo the whole team can see.
@Tag("smoke"); everything else @Tag("regression").mvn test -Dgroups=smoke and confirm the count matches your tagging.