Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Database state verification #47

Open
number133 opened this issue Oct 27, 2015 · 7 comments
Open

Database state verification #47

number133 opened this issue Oct 27, 2015 · 7 comments

Comments

@number133
Copy link

How about to add API to check database state? It would be nice to both initiate data and verify it after tests, not using software's own API.

@jnizet
Copy link
Member

jnizet commented Oct 31, 2015

Hello.

I've been asked for such a feature already (See #39). But I feel it's out of the scope of DbSetup: it would be quite a complex task, and I'm not sure I would end up with an API that would be easier to use than the software's own API.
It would also be problematic because the test would have to commit every change before using that new DbSetup API, otherwise the changes would not be visible to DbSetup.
In my experience, 99% of DAO tests are tests for methods that query the database and thus return results. The assertions can thus be made on these results. For the remaining 1%, most of the time, a simple query by ID method can be used after the insertion/update/delete to make sure the test did the right thing.
So I'm not sure it's worth the effort.
Do you have a specific use-case, and some pseudo-code, in mind?

@number133
Copy link
Author

Currently we are using DBSetup to initialize data for integration tests. We don't want use our own API to init data or check results, because we are planning significant refactoring. If we use our API, we can't rely on tests after the refactoring. So now I decide to use http://jdbi.org/ to verify results. DBSetup is quite easy, concise and powerful tool and it would be nice to have same style verification tool.

@isen-ng
Copy link

isen-ng commented May 9, 2016

+1

@raderio
Copy link

raderio commented Nov 30, 2018

@number133 how do you verify results using JDBI? Do you have an example?
Thanks.

@raderio
Copy link

raderio commented Nov 30, 2018

But I feel it's out of the scope of DbSetup

Maybe you can create a new repository for this, like DbExpect.

@raderio
Copy link

raderio commented Dec 4, 2018

What do you think about https://github.com/joel-costigliola/assertj-db ?

@raderio
Copy link

raderio commented Dec 5, 2018

Use case you setup & assert should be in one project is that you can reuse setup in tests.
https://github.com/JDBDT/jdbdt

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants