我在 SpringDBunit 中遇到浮点断言问题。我已阅读此question,但我使用的是MySql,无法更改数据库图层。我也检查了dbunit documentation,但也没有运气,仍然得到断言错误:
junit.framework.ComparisonFailure: value (table=tablename, row=0, col=colname)
Expected :0.35
Actual :0.35000000000000003
有没有办法设置"容忍"在SpringDBUnit中断言?
My MySqlDataFactory如下所示:
//MySqlDataTypeFactory is taken from a context
ToleratedDeltaMap.ToleratedDelta toleratedDelta = new ToleratedDeltaMap.ToleratedDelta("tablename","colname",0.001);
mySqlDataTypeFactory.addToleratedDelta(toleratedDelta);
DatabaseConfigBean
在上下文中定义如下:
<bean id="dbUnitDatabaseConfig" class="com.github.springtestdbunit.bean.DatabaseConfigBean">
<property name="datatypeFactory" value="#{testDataTypeFactory.getMySqlDataTypeFactory()}" />-
</bean>
提前致谢。