openrewrite / rewrite-testing-frameworks

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

`Mockito.mockStatic` unexpectedly removed in rewrite-testing-frameworks:2.19.0 #611

Closed protocol7 closed 2 months ago

protocol7 commented 2 months ago

What version of OpenRewrite are you using?

What is the smallest, simplest way to reproduce the problem?

  @Test
  void mockitoStatic() {
    rewriteRun(
            spec -> spec.recipe(new PowerMockitoMockStaticToMockito()),
            java(
                    """
                     package com.helloworld;

                     import static org.mockito.Mockito.mockStatic;
                     import org.mockito.MockedStatic;

                     public class Main {
                           private final MockedStatic<String> mocked = mockStatic(String.class);
                    }"""));
  }

Test fails due to the recipe removing = mockStatic(String.class), which causes compilation failure due to mocked never being initialised.

Laurens-W commented 2 months ago

Hey @protocol7!

Thanks for the provided test case! I took a look at it, confirmed the issue and proposed a change

protocol7 commented 2 months ago

Thanks!