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.

Issue using @ExpectedDataSet without @DataSet

See original GitHub issue

I’m using Spring Boot, Jooq, HikariCP, and Rider-Spring. For the most part, this combination works fine.

I have one test in one class that is marked @Test, @ExpectedDataSet and does nothing but insert a couple of records via JooQ, then verify their existence.

The class is annotated:

@RunWith(SpringRunner.class)
@JooqTest
@DBRider

The test works when run alone or only that class is run.

When I run it with multiple test classes, this one test in the one class fails with:

junit.framework.ComparisonFailure: row count (table=mytable) expected:<[2]> but was:<[0]>

The transaction is not only not visible, but isn’t rolled back either - the two records will be left in the database. It seems like some kind of Spring related connect / datasource / pool related issue that I’ve been unable to track down.

Today I realized that, when I add a @DataSet that has no relation to the actual test, this all works fine. I’m glad I found a work around, but it seems like there’s still something wrong.

Any ideas?

Thanks for you work on this!

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
jenskreidlercommented, May 31, 2019

Hi, depending on your setup it could solve your issue using @Commit (spring-test) or @DirtiesContext(…) (also from spring-test). Greetings

Am 31. Mai 2019 00:15:05 MESZ schrieb Possibly Cott notifications@github.com:

I’m using Spring Boot, Jooq, HikariCP, and Rider-Spring. For the most part, this combination works fine.

I have one test in one class that is marked @Test, @ExpectedDataSet and does nothing but insert a couple of records via JooQ, then verify their existence.

The class is annotated:

@RunWith(SpringRunner.class)
@JooqTest
@DBRider

The test works when run alone or only that class is run.

When I run it with multiple test classes, this one test in the one class fails with:

junit.framework.ComparisonFailure: row count (table=mytable) expected:<[2]> but was:<[0]>

The transaction is not only not visible, but isn’t rolled back either - the two records will be left in the database. It seems like some kind of Spring related connect / datasource / pool related issue that I’ve been unable to track down.

Today I realized that, when I add a @DataSet that has no relation to the actual test, this all works fine. I’m glad I found a work around, but it seems like there’s still something wrong.

Any ideas?

Thanks for you work on this!

– You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/database-rider/database-rider/issues/136

– Diese Nachricht wurde von meinem Android-Gerät mit K-9 Mail gesendet.

0reactions
rmpestanocommented, Jun 11, 2019

Also, disabling cachedConnections in DBUnit config may help, remembered it after looking at executor code here.

Ex:

@DBUnit(cacheConnection = false)
@RunWith(SpringRunner.class)
@SpringBootTest(classes = {SomeApplication.class, SomeConfig.class})
@ActiveProfiles("test")
@DBRider
Read more comments on GitHub >

github_iconTop Results From Across the Web

Database Rider Documentation
Assertion with regular expression in expected dataset; 5.3. ... CDI integration via interceptor to seed database without rule instantiation;.
Read more >
Joined Table Not Returning Expected Dataset
When I make copies of the two tables and populate them with hand-entered data, the query works exactly as it should producing the...
Read more >
Introduction to DBUnit - Baeldung
Learn how to set up database states for your unit tests using DBunit. ... the actual contents of a table with an expected...
Read more >
Managing test data with DbUnit - Unitils –
This way you can make each developer connect to its own unit test database schema and run the tests without interference with others....
Read more >
DbUnit check autogenerating id - Stack Overflow
During test one new database row was created (it presents in after test dataset, which I specify using @ExpectedDatabase annotation). The problem is...
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