question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Could not run parameterized with DBUnitRule with database rider > 1.2.9

See original GitHub issue

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);
   }
}

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:17 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
victor-costa-avanceecommented, Jul 19, 2021

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

1reaction
rmpestanocommented, Jul 14, 2021

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

Read more comments on GitHub >

github_iconTop Results From Across the Web

Database Rider Documentation
DBUnit rule is responsible for reading @DataSet annotation and prepare the database for each test. And. The following dataset.
Read more >
Working With SQL and Databases in Rider - YouTube
In this webinar, we'll show the basics of writing SQL queries and working with data in Rider. All described is also relevant to...
Read more >
Cannot connect to a database | JetBrains Rider Documentation
Databases can work locally, on a server, or in the cloud. ... If you specify a port as a parameter for the telnet...
Read more >
Problem with DBRider: NoSuchTableException "the table ...
When I use framework "database-rider" with my postgresql database for spring-boot application they don`t work properly.
Read more >
Database Rider: How to improve your DB tests
This framework makes it easier to perform integration tests. What we will get with Database Rider that we won't get with the other...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found