springtestdbunit / spring-test-dbunit

Integration between the Spring testing framework and DBUnit
http://springtestdbunit.github.com/spring-test-dbunit/
Apache License 2.0
475 stars 238 forks source link

Wildcards or regular expressions in @ExpectedDatabase #102

Closed patrickh1 closed 8 years ago

patrickh1 commented 8 years ago

It would be really useful if you could use wildcards or regular expressions when testing the content of columns in the expected database fields.

For example I am testing a stored procedure that does validation. If the validation fails then a message is written to the validationMessage column of the table that is being validated. These messages change constantly and it is a pain to update all of the expected data sets to reflect the changes. It would be enough for me to test if the message contained the text 'warning' or 'error'.

I have tried values such as 'warning' and '^.warning.$' but they are just compared literally.

It would also be really useful if you could test that a column was non-empty. This could be easily accomplished with regular expressions.

FingolfinTEK commented 8 years ago

This is a feature request to be made for DBUnit framework, but the fastest way to achieve the behavior you desire would be by overriding org.dbunit.dataset.datatype.StringDataType in your test codebase

philwebb commented 8 years ago

I agree with @FingolfinTEK that this should be a core DBUnit feature. I don't have that much time for this project so I'd rather keep the scope limited to just exposing standard DBUnit features.