database-rider: Could not run parameterized with DBUnitRule with database rider > 1.2.9

Lookup for method annotations fails with parametrized tests in DBUnitRule.apply:

java.lang.RuntimeException: Could not find method shouldJustRunMoreThanOneTime[0] on test class ParameterizedTest 

	at com.github.database.rider.core.util.AnnotationUtils.findAnnotation(AnnotationUtils.java:179)
	at com.github.database.rider.core.DBUnitRule.apply(DBUnitRule.java:57)
        ...

Running parameterized tests is fine with version 1.2.9 but fails with all later versions including 1.3.0 and 1.4.0

You may refer to this test case for verification:

@RunWith(Parameterized.class)
@DBUnit(url = "jdbc:h2:mem:test",  driver = "org.h2.Driver", user = "u", password = "p")
public class ParameterizedTest {

   private int given;
   private int expected;

   @Rule
   public final DBUnitRule dbUnitRule = DBUnitRule.instance();

   @Parameters
   public static Collection<Object[]> data() {
      return Arrays.asList(
            new Object[] {0,0},
            new Object[] {1,1},
            new Object[] {2,2}
      );
   }

   public ParameterizedTest(int given, int expected) {
      this.given = given;
      this.expected = expected;
   }

   @Test
   public void shouldJustRunMoreThanOneTime() {
      Assertions.assertThat(given).isEqualTo(expected);
   }
}

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 17 (9 by maintainers)

Commits related to this issue

Most upvoted comments

It seems to be working perfectly @rmpestano, great job, thank you!

Hi again @victor-costa-avancee, I couldn’t run your sample because of database setup so I tried to reproduce on quarkus dbunit sample which uses CDI but It’s working there, can you have a look? https://github.com/database-rider/database-rider/blob/1bd24f0c5aa659cebf91b045afd601d67bdb7140/rider-examples/quarkus-dbunit-sample/src/test/java/com/github/quarkus/sample/QuarkusDBUnitParameterizedTest.java#L32-L59

I hope It helps

Thank you very much. We integrated the latest version successfully.