spring-io / spring-javaformat

Apache License 2.0
795 stars 110 forks source link

Allow static import of AssertJ BDDAssertions #403

Closed vpavic closed 5 months ago

vpavic commented 7 months ago

Analogous to the allowed import BDDMockito, Spring JavaFormat should also allow static import of AssertJ's BDDAssertions.

Note that there's an additional commit in this PR that removes a duplicate exclude that has sneaked in.

wilkinsona commented 7 months ago

Analogous to the allowed import BDDMockito

This isn't quite the same as we're opinionated about the use of BDDMockito:

https://github.com/spring-io/spring-javaformat/blame/7db7c9765fbad3e1c0b8f021dc16533f9d5c10f2/spring-javaformat/spring-javaformat-checkstyle/src/main/resources/io/spring/javaformat/checkstyle/spring-checkstyle.xml#L122-L128

Arguably, we're also opinionated (although less so) about AssertJ as we're currently steering people towards assertThat. I'm not sure about making it easier for people to mix the two AssertJ styles or about moving to BDD-style AssertJ across the board. I'll see what the team thinks.

philwebb commented 7 months ago

While I'm not so keen to use this ourselves (due to the potential clash with Mockito), I don't think it's a bad thing to allow the import for those that want to use it. Folks can always add a rule to ban the import in their own code (much like we do with assertThatThrownBy in Spring Boot.