3

I have a scenario where the SQL query with a where condition will result in 2 Rows. How can assert if it is resulting in 2 rows? At present, the karate is throwing an error org.springframework.dao.IncorrectResultSizeDataAccessException: Incorrect result size: expected 1, actual 2

* def response = db.readRow( 'SELECT * from database_name.table_name  where id  = \"'+ id + '\";')

1 Answers1

2

I believe this should help you : https://github.com/intuit/karate#schema-validation

* def foo = ['bar', 'baz']
# should be an array of size 2
* match foo == '#[2]'

Also, you should use db.readRows instead of 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'
Adrien
  • 1,080
  • 4
  • 14