AssertJ vs JUnit

Use AssertJ for fluent and more readable assertions.

Photo by timJ on Unsplash

What’s the difference between JUnit and AssertJ

Why should I use AssertJ?

Took me less than half an hour to get AssertJ.

<dependency>
<groupId>org.assertj</groupId>
<artifactId>assertj-core</artifactId>
<version>3.16.1</version>
<scope>test</scope>
</dependency>
testImplementation 'org.assertj:assertj-core:3.13.2'
import static org.assertj.core.api.Assertions.*;

AssertJ in Action

.as(String description)

Testing Collections

Testing Exceptions

@Test(expected = IOException.class)

Conclusion

QA and free artist

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store