【问题标题】:Include other datasets from xml包括来自 xml 的其他数据集
【发布时间】:2012-11-06 16:15:57
【问题描述】:

DBUnit 建议使用Small Datasets,但我没有发现数据集中包含小数据集的示例。我需要类似于(伪代码)的东西

<dataset>
<!-- this tag is what I am looking for... ;-)-->
     <include_other_datasets_which_is_shared_between_different_datasets datasetname="other.xml"/>
<!-- normal xmldataset-definition begins... -->
<table name="foo">...</table>
</dataset>

有什么想法吗?

【问题讨论】:

    标签: java testing junit dbunit


    【解决方案1】:

    据我所知,dbUnit 中不存在这样的功能,而且你也不需要它。

    因为您可以简单地对不同的数据集执行多次操作。

    DatabaseOperation.CLEAN_INSERT.execute(conn, "first_table.xml");
    DatabaseOperation.CLEAN_INSERT.execute(conn, "second_table.xml");
    

    或在运行时使用CompositeDataSet 将多个数据集合并为一个。

    【讨论】:

    • 我确实需要这个功能,因为我写了一个使用 db-unit 的小工具。要使用这个工具,我只需要提供要插入的数据集,不需要 Java 代码。我现在的解决方案是:用逗号分隔数据集,然后插入它们。无论如何,CompositeDataSet 看起来很有希望。谢谢
    猜你喜欢
    • 1970-01-01
    • 2017-03-20
    • 2013-02-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-04-06
    相关资源
    最近更新 更多