openrewrite / rewrite-testing-frameworks

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

No "MigrateHamcrestToAssertJ" recipe is executed or changed in the entire test class #521

Closed Saturas89 closed 2 weeks ago

Saturas89 commented 3 weeks ago

What version of OpenRewrite are you using?

I am using

How are you running OpenRewrite?

I am using the Maven plugin, and my project is a single module project.

<plugin>
  <groupId>org.openrewrite.maven</groupId>
  <artifactId>rewrite-maven-plugin</artifactId>
  <version>5.32.1</version>
  <configuration>
    <activeRecipes>                                                    
      <recipe>org.openrewrite.java.testing.hamcrest.MigrateHamcrestToAssertJ</recipe>
    </activeRecipes>
  </configuration>
</plugin>

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

We have a simple testclass like this:

package *.model.internal;

import org.junit.Test;

import static org.hamcrest.core.IsEqual.equalTo;
import static org.hamcrest.core.IsNot.not;
import static org.hamcrest.MatcherAssert.assertThat;

public class IdentValueStringTest {

    private IdentValueString value = new IdentValueString();
    @Test
    public void testEquals() throws Exception {
        IdentValueString clone = value.clone();

        assertThat(value, equalTo(clone));

        value.setValue("anders");
        assertThat(value, not(equalTo(clone)));
    }

What did you expect to see?

That the methods and imports are replaced.

package *.model.internal;

import org.junit.Test;

import static org.assertj.core.api.Assertions.assertThat;

public class IdentValueStringTest {

    private IdentValueString value = new IdentValueString();
    @Test
    public void testEquals() throws Exception {
        IdentValueString clone = value.clone();

        assertThat(value).isEqualTo(clone);

        value.setValue("anders");
        assertThat(value).isNotEqualTo(clone);
    }

What did you see instead?

Nothing changed.

package *.model.internal;

import org.junit.Test;

import static org.hamcrest.core.IsEqual.equalTo;
import static org.hamcrest.core.IsNot.not;
import static org.hamcrest.MatcherAssert.assertThat;

public class IdentValueStringTest {

    private IdentValueString value = new IdentValueString();
    @Test
    public void testEquals() throws Exception {
        IdentValueString clone = value.clone();

        assertThat(value, equalTo(clone));

        value.setValue("anders");
        assertThat(value, not(equalTo(clone)));
    }
timtebeek commented 2 weeks ago

Looking closely at the packages used in your examples above I think this might be a duplicate of

Would you mind trying again with the the snapshot snapshot once the fix for that issue is merged?

Saturas89 commented 6 days ago

Looking closely at the packages used in your examples above I think this might be a duplicate of

Would you mind trying again with the the snapshot snapshot once the fix for that issue is merged?

Yes, its already done. Thank you.