首页 > 解决方案 > 单独运行时带有子句'in'的集成测试会导致错误

问题描述

我有一个集成(h2、spock、grails-2.5.5)测试,在 sql(gorm)咨询中运行。当一起运行所有测试“grails test-app”时,此测试工作正常,但是当我单独运行时,测试中断并显示以下错误:

count_subscriber_brands subscriber6_ on br2_.id=subscriber6_.brand_id left outer join account_subscriber brs3_ on subscriber6_.account_subscriber_id=brs3_.id left outer join account brs3_1_ on brs3_.id=brs3_1_.id left outer join product_subscriber_publish sp1_ on this_.id=sp1_.product_id where this_.gtin=? and ((sp1_.subscriber_id=? and sp1_.is_published=?) or (this_.status in (?, ?) and ((br2_.exclusive=? and brs3_.id=?) or br2_.exclusive is null or br2_.exclusive=?))) [22018-176]
    at org.h2.message.DbException.getJdbcSQLException(DbException.java:344)
    at org.h2.message.DbException.get(DbException.java:167)
    at org.h2.value.Value.convertTo(Value.java:902)
    at org.h2.expression.ConditionIn.getValue(ConditionIn.java:57)
    at org.h2.expression.ConditionAndOr.getValue(ConditionAndOr.java:87)
    at org.h2.expression.ConditionAndOr.getValue(ConditionAndOr.java:110)
    at org.h2.expression.ConditionAndOr.getValue(ConditionAndOr.java:94)
    at org.h2.expression.Expression.getBooleanValue(Expression.java:179)
    at org.h2.command.dml.Select.queryFlat(Select.java:535)
    at org.h2.command.dml.Select.queryWithoutCache(Select.java:646)
    at org.h2.command.dml.Query.query(Query.java:323)
    at org.h2.command.dml.Query.query(Query.java:291)
    at org.h2.command.dml.Query.query(Query.java:37)
    at org.h2.command.CommandContainer.query(CommandContainer.java:91)
    at org.h2.command.Command.executeQuery(Command.java:197)
    at org.h2.jdbc.JdbcPreparedStatement.executeQuery(JdbcPreparedStatement.java:109)
    ... 7 more
Caused by: java.lang.NumberFormatException: For input string: "INACTIVATED"
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
    at java.lang.Integer.parseInt(Integer.java:580)
    at java.lang.Integer.parseInt(Integer.java:615)
    at org.h2.value.Value.convertTo(Value.java:852)
    ... 20 more

gorm 子句包含 'in'('status', [FINE, WORK, INACTIVATED])

当我单独运行时,测试也很好

标签: grailsintegration-testinggrails-ormgrails-2.5

解决方案


推荐阅读