参数和断言语句中的变量没有被替换
variables are not replaced in the parameters and assertion statements
我有下面的代码
#create document type
* print 'create document type'
* def documentTypeNameValue = 'sum2'
* print documentTypeNameValue
* def result = call read('classpath:examples/commonResources/documentTypes/createDocumentType.feature') { X-CSRF-TOKEN: csrfToken, JSESSIONID: jsessionid, documentTypeName: documentTypeNameValue, inputFile: 'examples/commonResources/documentTypes/add2NumbersDoc.json'}
Then match result.response.integration.message.description contains 'Success'
Then match result.response.integration.serviceData.message contains '#(documentTypeNameValue)' +' created successfully'
变量'documentTypeNameValue'在打印语句中正确打印
但是当我试图在作为参数传递给特征文件时使用相同的变量并且在资产声明期间这个变量没有被实际值替换('这里是 sum2)
请提出一些将变量值替换为参数以及断言中的解决方案
我也附上截图供参考
很难理解。所以我可能帮不上什么忙。
2 件事。
当 JSON 键中有连字符时,您需要使用引号,否则它是无效的 JSON { 'X-CSRF-TOKEN': '#(csrfToken)' }
而且您没有在需要的地方使用嵌入式表达式。
你又犯了同样的错误,嵌入表达式应该是整个 RHS 字符串值或 JSON 值。
您可以改为执行此操作(普通 JS)。请仔细阅读文档,尤其是 Karate Expressions.
部分
Then match result.response.integration.serviceData.message contains documentTypeNameValue + ' created successfully'
我有下面的代码
#create document type
* print 'create document type'
* def documentTypeNameValue = 'sum2'
* print documentTypeNameValue
* def result = call read('classpath:examples/commonResources/documentTypes/createDocumentType.feature') { X-CSRF-TOKEN: csrfToken, JSESSIONID: jsessionid, documentTypeName: documentTypeNameValue, inputFile: 'examples/commonResources/documentTypes/add2NumbersDoc.json'}
Then match result.response.integration.message.description contains 'Success'
Then match result.response.integration.serviceData.message contains '#(documentTypeNameValue)' +' created successfully'
变量'documentTypeNameValue'在打印语句中正确打印 但是当我试图在作为参数传递给特征文件时使用相同的变量并且在资产声明期间这个变量没有被实际值替换('这里是 sum2)
请提出一些将变量值替换为参数以及断言中的解决方案
我也附上截图供参考
很难理解。所以我可能帮不上什么忙。
2 件事。
当 JSON 键中有连字符时,您需要使用引号,否则它是无效的 JSON { 'X-CSRF-TOKEN': '#(csrfToken)' }
而且您没有在需要的地方使用嵌入式表达式。
你又犯了同样的错误,嵌入表达式应该是整个 RHS 字符串值或 JSON 值。
您可以改为执行此操作(普通 JS)。请仔细阅读文档,尤其是 Karate Expressions.
部分Then match result.response.integration.serviceData.message contains documentTypeNameValue + ' created successfully'