我一直在使用SOAP UI工具来测试我的Web服务是否符合Schema。我想将架构遵从失败导出到Excel或文本文件。有没有可能的方法来做到这一点?将断言失败写入SOAP UI的文本文件或Excel工作表
谢谢
我一直在使用SOAP UI工具来测试我的Web服务是否符合Schema。我想将架构遵从失败导出到Excel或文本文件。有没有可能的方法来做到这一点?将断言失败写入SOAP UI的文本文件或Excel工作表
谢谢
我找到了答案,通过搜索网络多一点。 :)
我们可以在SOAP UI中使用Groovy脚本来实现此目的。
filePath = 'D:/SchemaComplianceResult/'
def project = testRunner.testCase.testSuite.project
fos = new FileOutputStream(filePath + project.name + '.txt', true)
pw = new PrintWriter(fos)
def runner = project.testSuites['TestSuite 1'].testCases['TestCase 1'].run(null, true)
runner.waitUntilFinished()
def errArray = runner.testCase.getTestSteps()["Request 1"].getAssertionByName("Schema Compliance").getErrors()
pw.println(runner.results[0].getResponseContentAsXml())
pw.println("Schema Compliance Results:")
for(err in errArray){
pw.println("Line Number:" + err.getLineNumber()+ "Error Message:" + err.getMessage())
}
pw.close()
fos.close()
希望它有帮助。
解决此问题的更一般方法是生成报告。 SOAPUI允许生成不同格式的报告,包括SOAPUI免费版本中的Junit风格报告。当然,这份报告将显示每个测试案例失败的原因。