我使用 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>
当我在测试中从数据库加载第二个用户时, boolean 字段 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 运行测试。
知道为什么除了 boolean 值之外的所有字段都被映射了吗?
最佳答案
因为值应该是TRUE
或FALSE
关于java - dbunit 数据集没有将 boolean 字段放入数据库,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10101521/