Java Test Automation / Quiz
Assertion Wars: TestNG vs AssertJ vs Hamcrest
Three dialects, one job. Argument orders, fluent chains, matcher composition, and the SoftAssert that fails silently without assertAll().
- Difficulty
- Medium
- Format
- Quiz
- Points
- 150
- Estimate
- 9 min
// MISSION BRIEF
Your Mission
Java test code speaks three assertion dialects: TestNG/JUnit's classic asserts, AssertJ's fluent chains, and hamcrest's composable matchers. Each has a home turf, and one of them has a famous silent failure mode.
This quiz makes you fluent in all three, including the soft-assertion patterns that gather ALL the bad news before failing.
// FIRST CONTACT
Battle teaser
TestNG's Assert.assertEquals parameter order is:
- AOrder does not matter, equality is symmetric
- BTestNG only accepts a single argument
- CassertEquals(expected, actual), same as JUnit
- DassertEquals(actual, expected), the reverse of JUnit's (expected, actual); getting it wrong flips every failure message
Answers, scoring, hints, and the full battle stay sealed.
// SKILL TAGS
javaassertionsassertjsoft-asserts