【问题标题】:dbunit dataset does not put boolean field into dbdbunit 数据集没有将布尔字段放入 db
【发布时间】:2012-04-11 07:16:09
【问题描述】:

我使用 DbUnit 进行集成测试。我有以下数据集。

<?xml version='1.0' encoding='UTF-8'?>
<dataset xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="dataset.xsd">
    <USERS ID="1" EMAIL="" LASTNAME="A" LASTMODIFIED="2001-01-01 00:00:00.0" />
    <USERS ID="2" EMAIL="" LASTNAME="D" LASTMODIFIED="2001-01-01 00:00:00.0" ACTIVE="true" />
</dataset>

当我在测试中从数据库加载第二个用户时,不知何故没有在第二个用户上设置布尔字段 ACTIVE。

测试看起来像这样:

@SpringApplicationContext("component-context-test-dao.xml")
@DataSet
public class UserDaoImplIT extends UnitilsJUnit4 {

@SpringBeanByType
private UserDaoImpl userDao;

@Test
public void shouldReturnTrueIfFoundActiveUserWithEmail() throws InterruptedException {
    boolean exits = userDao.isEmailFromActiveUserInUsers("anEmailThatDoesNotExist@oeamtc.at");
    List list = HibernateUnitils.getSession().createQuery("from User").list();
    assertThat(exits, is(true));

}
}

我在 Eclipse 中针对内存中的 h2 运行测试。

任何想法为什么除了布尔值之外的所有字段都被映射?

【问题讨论】:

    标签: java integration-testing dbunit


    【解决方案1】:

    因为值应该是TRUEFALSE

    Datatypes - boolean type

    【讨论】:

      猜你喜欢
      • 2015-03-24
      • 1970-01-01
      • 1970-01-01
      • 2011-08-28
      • 1970-01-01
      • 2011-02-21
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多