openrewrite / rewrite-testing-frameworks

OpenRewrite recipes that perform common Java testing migration tasks.
Apache License 2.0
68 stars 59 forks source link

convert `AssertTrue(false)` to `fail` #464

Open timo-abele opened 5 months ago

timo-abele commented 5 months ago

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

timtebeek commented 5 months ago

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

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!