Recipe testing best practices

MSAL

Best practices for testing recipes.

org.openrewrite.java.recipes.RecipeTestingBestPractices
mod run . --recipe=org.openrewrite.java.recipes.RecipeTestingBestPractices

Install it once from Recipe actions, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.

Recipe list

It runs these recipes, in this order.

  1. Replace Stream.collect(Collectors.toUnmodifiableList()) with Stream.toList()
  2. One classpath argument per line
  3. RewriteTest classes should not be public
  4. Automatically select recipe examples from the unit test cases of a recipe
  5. Single @DocumentExample per test class
  6. Show @DocumentExamples first
  7. Replace null with RewriteTest.doesNotExist()
  8. New line at the end of SourceSpecs text blocks
  9. Minimal indentation for SourceSpecs text blocks
  10. Refactor RewriteTest to use defaults method
  11. Remove RecipeSpec.cycles(int) calls that restate the default
  12. Find method calls and say what to do instead
  13. Find method calls and say what to do instead
  14. Find method calls and say what to do instead
  15. Use StringUtils utility methods
  16. Use var for variables initialized with type casts
  17. Use var for constructor call assignments
  18. Apply var to generic constructors
  19. Apply var to generic method invocations
  20. Use var for primitive and String variables
  21. Use modernized java.util APIs
  22. Convert Javadoc to Markdown documentation comments
  23. JUnit 6 best practices
  24. AssertJ best practices
  25. Fix missing braces
  26. Remove System.out#println and System.err#println statements
  27. Reorder annotations alphabetically
  28. Use static import org.openrewrite..Assertions *(..)
  29. Use static import org.openrewrite.test.RewriteTest *(..)
  30. Use static import org.openrewrite.test.SourceSpecs *(..)
  31. Change method target to static
  32. Change method name java.util.List asList(..) to of