{ assertTrue(fun.getFavoriteActivity().startsWith("swim"), "expected to start with 'swim' but was " + fun.getFavoriteActivity()); assertTrue(fun.getFavoriteActivity().startsWith("tennis"), "expected to start with 'tennis' but was " + fun.getFavoriteActivity()); } org.opentest4j.AssertionFailedError: expected to start with 'tennis' but was swimming ==> Expected :true Actual :false
updates • Multiple or combined assertions • Integration with JUnit 4 assertThat or standalone in JUnit 5 AssertJ • Fluent • Newer • More updates • Chaining assertions (faciliates autocomplete) • Can use with JUnit 4 or 5
= new SoftAssertions(); softly.assertThat(“robot") .isEqualTo("izzy"); softly.assertThat(126) .isLessThanOrEqualTo(125); softly.assertAll();; } org.assertj.core.error. AssertJMultipleFailuresError: Multiple Failures (2 failures) -- failure 1 -- expected: "izzy" but was: "robot" at SoftAssertionsTest.calling… -- failure 2 -- Expecting actual: 126 to be less than or equal to: 125 at SoftAssertionsTest.calling…
public CustomAssertions(String actual) { super(actual, CustomAssertions.class); } public static CustomAssertions assertThat(String actual) { return new CustomAssertions(actual); } public CustomAssertions isTennis() { if (! "tennis".equals(actual)) failWithMessage("Must be tennis but was %s", actual); return this; } }
partner service to be ready") void waitingForServiceAvailability() { … } timestamp = 2025-07-05T11:50:33.673759, DisabledUntil = This test is disabled until 2025-10-31. If executing it on this commit would fail, the build can't be reproduced after that date. The `date` 2025-10-31 is after the current date 2025-07-05
var options = new ChromeOptions(); options.addArguments("--headless=new"); driver = new ChromeDriver(options); … } finally { if (driver != null) driver.close(); }