【问题标题】:Ignore columns in ExpectedDataSet (dbunit)忽略 ExpectedDataSet (dbunit) 中的列
【发布时间】:2013-09-30 15:48:24
【问题描述】:

如何忽略使用ExpectedDataSet注解的一些列的比较?

  • 我使用dbunit API。

【问题讨论】:

    标签: java spring dbunit


    【解决方案1】:

    在spring中使用spring-test-dbunit,可以这样写:

    @ExpectedDatabase(value="yourdataset.xml", assertionMode=DatabaseAssertionMode.NON_STRICT)

    并省略“yourdataset.xml”上的列

    参考:http://springtestdbunit.github.io/spring-test-dbunit/

    【讨论】:

    • 我的情况是我有两个表,其中一个表对另一个表有外键约束,并且引用是另一个表的字段“id”,它将在每次插入时自动递增,并且不能省略这个引用关系,当我运行单元测试时,id不匹配(期望1但实际值大于1并且增加)发生的compareFailure,这种情况该怎么办?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-01-23
    • 2012-08-11
    • 1970-01-01
    • 2021-08-15
    • 2021-08-21
    相关资源
    最近更新 更多