Run AssertJ best practices OpenRewrite recipe#456
Conversation
https://docs.openrewrite.org/reference/recipes/java/testing/assertj/assertj mvn org.openrewrite.maven:rewrite-maven-plugin:4.36.0:run \ -Drewrite.recipeArtifactCoordinates=org.openrewrite.recipe:rewrite-testing-frameworks:1.30.0 \ -DactiveRecipes=org.openrewrite.java.testing.assertj.Assertj
Codecov Report
@@ Coverage Diff @@
## main #456 +/- ##
============================================
- Coverage 93.00% 92.95% -0.05%
+ Complexity 2096 2094 -2
============================================
Files 233 233
Lines 4374 4374
Branches 449 449
============================================
- Hits 4068 4066 -2
- Misses 190 191 +1
- Partials 116 117 +1
📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
|
Thanks for this PR, much appreciated! |
|
You're welcome; let me know if there's any other types of automated improvements you'd want me to take a look at. |
|
@timtebeeko thanks! There might be a thing, but it could be a tricky one : some of our assertions are pretty useless. They basically test that methods are returning something, and that's about it. Something slightly stricter might be nice. That might be hard to do with static code analysis, but open to suggestions! |
|
Hmm yes closest thing I could find in OpenRewrite on that so far is TestsShouldIncludeAssertions, with some test examples in TestsShouldIncludeAssertionsTest. Not an exact match to what you're looking for, but open to suggestions on how to improve that one or write a new one. An alternative in that space might be DiffBlue Cover. Fairly new (and pricey), but they have a free trial and might be able to help out for OSS projects. Ideally you'd pinpoint exact area's for improvement through mutation testing and see from there. |
Consistently use static imports for AssertJ, as a once of code change, through OpenRewrite.