错误 NoSuchColumnException DbUnit

error NoSuchColumnException DbUnit

我有一个 table 和一个 JSON 列,当我 运行 我对数据集进行测试时。

org.dbunit.dataset.NoSuchColumnException: hero.JSON - (Non-uppercase
input column: json) in ColumnNameToIndexes cache map. Note that the map's
column names are NOT case sensitive.

我的数据集:

 <?xml version="1.0" encoding="UTF-8"?>
 <dataset>

   <hero id='000580548' json='{"id" : 1,"name" : "mySuperHero"}'/>
   <hero_profile id='000580548-mySuperHero' json='{"habilities": [], "stars" : 7}'/>
</dataset>

Obs:我的 tables 已经存在于数据库中。

默认情况下 DbUnit 不理解 json 字段设置。 您要么在测试中省略它,要么为 DbUnit

编写自定义扩展

你可以用技巧来做到这一点:

<hero 
id="000580548" 
json="{&quot;id&quot; : 1,&quot;name&quot; : &quot;mySuperHero&quot;}"
/>

对我们有用。