断言结果如何只得到计数
how assert result get count number only
我想断言 sql 查询中的计数 return 是正确的,但在使用断言时遇到错误。
我可以使用哪个断言来检查计数?或者 printIn 只计算数字?
代码
//SQL statement
String dbQuery = "SELECT COUNT(*) FROM item.items WHERE drugid LIKE '%KP%'"
//Connect to SQL Server, global variable is stored at profile
List results = CustomKeywords.'DB.getSQLResults'(GlobalVariable.dbConnString , GlobalVariable.dbUsername , GlobalVariable.dbPassword ,GlobalVariable.dbDriver ,dbQuery )
//ensure total count
println results
assert results == "[:101]"
结果:
println(results)
[[:101]]
assert results == "[:101]"
Test Cases/Database Test FAILED.
Reason:
Assertion failed:
assert results == "[:101]"
| |
| false
[[:101]]
看起来你那里有地图列表。
assert results == [['':101]]
assert results[0].get('') == 101
两者都应该 return 为真。
此外,如果您将 SQL 更改为
String dbQuery = "SELECT COUNT(*) as count FROM item.items WHERE drugid LIKE '%KP%'"
你应该得到
assert results == [[count:101]]
assert results[0].count == 101
我想断言 sql 查询中的计数 return 是正确的,但在使用断言时遇到错误。 我可以使用哪个断言来检查计数?或者 printIn 只计算数字?
代码
//SQL statement
String dbQuery = "SELECT COUNT(*) FROM item.items WHERE drugid LIKE '%KP%'"
//Connect to SQL Server, global variable is stored at profile
List results = CustomKeywords.'DB.getSQLResults'(GlobalVariable.dbConnString , GlobalVariable.dbUsername , GlobalVariable.dbPassword ,GlobalVariable.dbDriver ,dbQuery )
//ensure total count
println results
assert results == "[:101]"
结果:
println(results)
[[:101]]
assert results == "[:101]"
Test Cases/Database Test FAILED.
Reason:
Assertion failed:
assert results == "[:101]"
| |
| false
[[:101]]
看起来你那里有地图列表。
assert results == [['':101]]
assert results[0].get('') == 101
两者都应该 return 为真。
此外,如果您将 SQL 更改为
String dbQuery = "SELECT COUNT(*) as count FROM item.items WHERE drugid LIKE '%KP%'"
你应该得到
assert results == [[count:101]]
assert results[0].count == 101