rewrite-testing-frameworks icon indicating copy to clipboard operation
rewrite-testing-frameworks copied to clipboard

convert `AssertTrue(false)` to `fail`

Open timo-abele opened this issue 1 year ago • 1 comments

What problem are you trying to solve?

I have in my code some (Junit5) AssertTrue(false, "this shouldn't happen"), because someone didn't use fail when they should have.

Describe the solution you'd like

The Junit5 cleanup recipe should convert such cases to fail("this shouldn't happen"). The AssertJ best pratices recipe might add a similar recipe.

Have you considered any alternatives or workarounds?

Additional context

Are you interested in contributing this feature to OpenRewrite?

no

timo-abele avatar Jan 18 '24 17:01 timo-abele

Hi @timo-abele ; Yes would fit right in with some of the other AssertTrue migration recipes we already have in https://github.com/openrewrite/rewrite-testing-frameworks/tree/a426e409ca3b8e04c6470e86cc09d61346e7c0f4/src/main/java/org/openrewrite/java/testing/cleanup

We could even implement this as a Refaster recipe, similar to what we recently added to rewrite-static-analysis in

  • https://github.com/openrewrite/rewrite-static-analysis/pull/231

Given that there's good examples to work from already I'm going to mark this one as good first issue; anyone welcome to pick this up!

timtebeek avatar Jan 18 '24 17:01 timtebeek