小编Sne*_*kla的帖子

每次在空手道 dsl 中运行测试时如何创建随机字符串

我发送的 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
Run Code Online (Sandbox Code Playgroud)

我在我的请求中发送名称,TestbyKarate但我想在每次测试运行时发送一个唯一值。

有什么办法吗?

dsl karate

4
推荐指数
1
解决办法
3847
查看次数

如何在空手道中使用 if 条件进行动态响应代码

我正在尝试运行一些测试,Delete.feature如果成功,则需要在每个场景结束时调用“”文件,但如果是失败测试,​​则不应调用“ Delete.feature”文件。

我的测试看起来像这样:

Given url ApiAdminURL

And path AdminPath

And header apigateway-apikey = apiGatewayKey

And header apigateway-basepath = 'lambdaTest'

* json myReq = read('users.json')

* set myReq.apiConf.subscriptionTiers = subscriptionTiers

* print 'my subscriptions : ', myReq.apiConf

And request myReq 

When method post

Then status responseCode

* call read('Delete.feature')

Examples:

| subscriptionTiers                     |responseCode|               
| [Unlimited,Gold,Bronze, Silver]       |200         |
| [Unlimited,Gold,Bronze]               |200         |
| [Unlimited,Gold,BronzeAuto-Approved]  |400         | 
Run Code Online (Sandbox Code Playgroud)

如果响应代码是200,那么它应该运行命令“ * call read('Delete.feature')”,如果responseCode400,那么它应该跳过这个命令。

有人可以帮我吗?

dsl karate

3
推荐指数
1
解决办法
3万
查看次数

标签 统计

dsl ×2

karate ×2