Reputation: 3986
Is it possible to create an ArchUnit rule which prevents AssertJ statements without an assertion?
For exampel: This AssertJ statement is perfectly ok, because it has both a assertThat
part and an assertion.
assertThat(frodo.getName()).isEqualTo("Frodo");
I need a ArchUnit rule which will let the build fail when something like this is found:
assertThat(frodo.getName());
This is a assertThat
statement without an assertion. This line of code will never throw an Assertion exception.
Upvotes: 0
Views: 194
Reputation: 3062
I don't think that ArchUnit can catch such statements, but some static code analysis tools can, cf. Verify that assertions have been called in Assertj.
Upvotes: 1