Skip to content

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

2 participants