【发布时间】:2017-03-03 07:16:15
【问题描述】:
我有一个功能文件如下
Feature: Test send API request
In order to test my API
As a Tester
I want to be able to perform HTTP request
Scenario:Sending GET request to activate user after registration api to verify whether the response code is 403 when 'X-Auth-Token' is missing
When I have a request "GET /api/activateuser?token=:tokenhash"
And I set the "Accept" header to "application/json"
And I set the "X-Auth-Token" header to "0125ee8dfe42bafbec95aa0d2676c91d8a780715b76504cf798aae6e74c08a30"
.
.
Scenario:Sending GET request to activate user after registration api to verify whether the response code is 403 when 'X-Auth-Token' is invalid
When I have a request "GET /api/activateuser?token=:tokenhash"
And I set the "Accept" header to "application/json"
And I set the "X-Auth-Token" header to "0125ee8dfe42bafbec95aa0d2676c91d8a780715b76504cf798aae6e74c08a30"
.
.
Scenario:Sending GET request to activate user after registration api to verify whether the response code is 404 when userid is invalid
When I have a request "GET /api/activateuser?token=:tokenhash"
And I set the "Accept" header to "application/json"
And I set the "X-Auth-Token" header to "0125ee8dfe42bafbec95aa0d2676c91d8a780715b76504cf798aae6e74c08a30"
.
.
请求中的'X-Auth-Token'参数对于所有的scnerios都是一样的,不会经常改变。所以我正在考虑将其设置为某个变量并在场景中使用该变量。但是还没有找到任何方法来做到这一点。即使我们可以在 behat.yml 中设置值并在场景中使用它也没关系,但即使这样也不可能。
我还有不止一个参数需要这样设置。
那么有什么方法可以设置一次值并在每个场景中重复使用它吗?
【问题讨论】:
标签: testing automated-tests symfony bdd behat