我有一个场景,其中带where条件的SQL查询将导致2行。如何断言是否导致2行?目前,空手道抛出错误org.springframework.dao.IncorrectResultSizeDataAccessException:错误的结果大小:预期为1,实际为2
* def response = db.readRow( 'SELECT * from database_name.table_name where id = \"'+ id + '\";')
答案 0 :(得分:2)
我相信这会对您有所帮助:https://github.com/intuit/karate#schema-validation
* def foo = ['bar', 'baz']
# should be an array of size 2
* match foo == '#[2]'
此外,您应该使用db.readRows而不是db.readRow。
* def dogs = db.readRows('SELECT * FROM DOGS')
* match dogs contains { ID: '#(id)', NAME: 'Scooby' }
* def dog = db.readRow('SELECT * FROM DOGS D WHERE D.ID = ' + id)
* match dog.NAME == 'Scooby'