Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

When migrating from JUnit to AssertJ, rely on context to provide better assertions #387

Open
rahulsom opened this issue Jul 21, 2023 · 1 comment
Labels
enhancement New feature or request recipe Recipe request

Comments

@rahulsom
Copy link

What problem are you trying to solve?

I'm converting JUnit assertions to AssertJ assertions.

Describe the solution you'd like

In the example here - https://docs.openrewrite.org/recipes/java/testing/assertj/junitasserttruetoassertthat

assertTrue(notification() != null && notification() > 0);

is turned into

assertThat(notification() != null && notification() > 0).isTrue();

The more useful conversion would be

assertThat(notification()).isNotNull().isGreaterThan(0)

Have you considered any alternatives or workarounds?

N/A

Additional context

Are you interested in contributing this feature to OpenRewrite?

@rahulsom rahulsom added the enhancement New feature or request label Jul 21, 2023
@timtebeek
Copy link
Contributor

Hi @rahulsom , thanks for reporting this suggestion here! It sounds like this issue could tie in with the work being done on #348, which will make it's way into our AssertJ best practices. In particular I think we can split the && first into two assertion statements, and then collapse those statements using the recipe developed in #373.

@timtebeek timtebeek added the recipe Recipe request label Jul 21, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request recipe Recipe request
Projects
Status: Recipes Wanted
Development

No branches or pull requests

2 participants