我需要断言一个java.io.StringReader格式的响应。。当我使用response.data时,我能够得到正确的响应{"isValid":false}。但是,当我尝试使用以下命令断言此响应时
response.data == '{"isValid": false}'我得到了下面的错误。
Condition not satisfied:
response.data == '{"isValid": false}'
| | |
| | false
| java.io.StringReader@35636217
groovyx.net.http.HttpResponseDecorator@5e4fa1da如何解析StringReader格式。
发布于 2017-02-22 00:37:15
我想通了。def jsonSlurper =新JsonSlurper().parse(response.data) jsonSlurper == virtualCard:false
发布于 2017-02-21 18:04:58
如何将isValid检查为false
assert !response.data.isValid, 'isValid is not matching the expected value'编辑:基于OP的评论。
def str = '''{"isValid": false}'''
def value = new groovy.json.JsonSlurper().parseText(str).isValid
assert response.data == value, 'isValid is not matching the expected value'https://stackoverflow.com/questions/42359164
复制相似问题