This is the suite's regression gate. Answer every question, then run the suite. Wrong answers show an explanation — read it, then re-run. In this course, like on a real team, you don't merge on a red build.
01. @BeforeEach vs @BeforeAll:
identical @BeforeEach runs before every test; @BeforeAll runs once per class (and must be static) @BeforeAll runs before every test @BeforeEach is TestNG-only
Per-test setup (fresh browser) goes in @BeforeEach; expensive one-time setup (config, test data) in static @BeforeAll.
02. Why does driver.quit() belong in @AfterEach rather than at the end of each test?
It runs faster there @AfterEach is guaranteed to run even when the test fails mid-way quit() is illegal inside @Test it enables parallelism
A failing assertion aborts the test method — code after it never runs. Lifecycle hooks run regardless, so no leaked browsers.
03. assertEquals(actual, expected) — arguments swapped — causes…
a compile error failure messages that lie: “expected <the bug> but was <the truth>” the test to always pass nothing; order is irrelevant
It's (expected, actual). Swapped arguments still compile and still fail correctly — but the message misleads whoever debugs at 2 a.m.
04. In @CsvSource, the value '' represents…
a null a skipped row an empty string — boundary cases are first-class test data a comment
Empty-string boundaries (blank username!) are exactly the rows your test-design instincts should feed the framework.
05. Each test gets a fresh browser because…
Chrome crashes otherwise shared state between tests is the silent killer of reliability — test 3 fails because test 2 left the app somewhere odd Selenium requires it it's faster than reusing one
Independence costs a little speed and buys trustworthiness — and it's what makes parallel execution safe later.
06. Run only the tests tagged smoke:
mvn test -Dtest=smokemvn smokemvn test -Dgroups=smokemvn test --tag smoke
-Dgroups filters by @Tag. That's how CI runs smoke on every push and the full suite nightly.
07. Automatic screenshots at the moment of failure are wired with…
a TestWatcher extension in BaseTest a Maven plugin Chrome's built-in recorder @Screenshot annotation
TestWatcher.testFailed() fires on any failure; TakesScreenshot photographs the browser. Evidence turns “re-run it” into “diagnosed in seconds.”