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

Allow database assertion to be defined as a bean #117

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

mikebl71
Copy link

Problem to solve:
I would like to implement a custom logic for validating actual vs expected datasets.
Spring-dbunit uses DatabaseAssertion objects for such validations.
However, at present, the ExpectedDatabase annotation only accepts DatabaseAssertionMode. But DatabaseAssertionMode is an enum, which means that I cannot extend it in my project.

Proposed solution:
Similar to how you have "dataSetLoader" and "dataSetLoaderBean" elements in DbUnitConfiguration, I've added an "assertionBean" element to ExpectedDatabase. So now I can define any database assertion I like as a bean and refer to it in the annotation.

Example:

@Bean
public DatabaseAssertion dbAssertion() {
    return new CustomDatabaseAssertion();
}

@Test
@ExpectedDatabase(value = "classpath:/datasets/Expected.xml",
        assertionBean = "dbAssertion")
public void test() throws Exception {
    ....

@Toilal
Copy link
Contributor

Toilal commented Aug 25, 2016

It would be great to also define the default assertion bean.

@Toilal
Copy link
Contributor

Toilal commented Aug 25, 2016

Thanks for your pull request. I've create another one, more complete because it also allow to defined default assertion bean and/or class.

#120

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

Successfully merging this pull request may close these issues.

2 participants