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

how to write custom DatabaseAssertionMode #109

Closed cwt9562 closed 7 years ago

cwt9562 commented 8 years ago

I meet an assertion exception when using @ExpectedDatabase like this:

junit.framework.ComparisonFailure: value (table=account, row=0, col=update_time) Expected :2016-06-21 20:11:56 Actual :2016-06-21 20:11:56.027

so I want to write own DatabaseAssertionMode class to ignore microsecond for timestamp.

FingolfinTEK commented 8 years ago

That is DBUnit-level issue and currently the only way to do it would be to override TimestampDataType class in your test code and add the support you want. But my suggestion would be to use a mocking framework like JMockit and just mock your date classes to return a predictable value which you would then pass as a parameter to your data set.