我发送的json请求是:
Given url applicationURL
And path 'applications'
And header Authorization = subscribeToken
And request:
{
"throttlingTier": "Unlimited",
"description": "sample app description",
"name": "TestbyKarate",
"callbackUrl": "https:/apistore-dev-dev-a878-14-ams10-nonp.qcpaws.qantas.com.au/callback"
}
When method post
Then status 201
* def applicationId = response.applicationId
* print 'applicationId is ', applicationId
我在请求中将名称发送为TestbyKarate
,但我希望每次运行测试时都发送一个唯一值。
有什么办法吗?
答案 0 :(得分:1)
可以请您一次阅读文档。它将真的使您受益。
https://github.com/intuit/karate#commonly-needed-utilities
因此,在Background
或常用功能中,您具有:
* def now = function(){ return java.lang.System.currentTimeMillis() }
然后您可以执行以下操作:
* def name = 'Test-' + now()
* request { name: '#(name)' }