我需要比较 SoapUI 中的两个字符串。第一个来自存储在本地目录中的文本文件,第二个来自我从 REST API 操作获得的 XML 响应。在比较这两个字符串之前,我对它们使用了一些方法来删除标题,因为它们包含诸如日期和处理时间之类的信息,这些信息肯定每次都不同。
以下是我尝试过的。
def xml = messageExchange.responseContentAsXml
String fileData = new File("C://Users/362784/project/outputPGB123.txt").text
String responseContent = new XmlSlurper().parseText(xml)
String fileDataFiltered = fileData.substring(fileData.indexOf("PASSED :"))
String responseContentFiltered = responseContent.substring(responseContent.indexOf("PASSED :"))
log.info(fileDataFiltered)
log.info(responseContentFiltered)
assert fileDataFiltered == responseContentFiltered
这是我收到的错误
和我的两个相同的 log.info
我是 SoapUI 的新手,我不确定这两者实际比较的是什么,但我已经在https://www.diffchecker.com/diff上检查了它们的 log.info,内容是相同的。但是,此断言返回错误。
谁能指出我做错了什么以及如何获得通过的结果?