我有问题。我正在使用量角器 - 黄瓜 - 框架。
我的功能文件
上有这个黄瓜测试用例<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
<div class="outer" id="content">
<button class="lefty paddle" id="left-button"></button>
<div class="inner" style="background:red"></div>
<div class="inner" style="background:green"></div>
<div class="inner" style="background:blue"></div>
<div class="inner" style="background:yellow"></div>
<div class="inner" style="background:orange"></div>
<button class="righty paddle" id="right-button"></button>
</div>
鉴于我有3个环境(开发,测试和现场)
在开发中我有:User1和User2
在测试中我有:User3和User4
在现场我有:User5和User6
我需要为每个用户做一个测试用例,共计6个测试用例。
qwestion是:有没有办法在6次测试中使用相同的Scenario黄瓜?。
谢谢!
答案 0 :(得分:0)
将其转换为 ScenarioOutline ,并将示例表拆分为3.在运行器中使用过滤器,以查找要运行的环境。
Scenario Outline: login successfully
Given I am in mypage
When I fill the fields with data
| key | value |
| user | <userValue> |
| pass| <passValue> |
And I push on login button
Then I am logged in with my credentials
@dev
Examples:
|userValue|passValue|
|user1|pass1|
|user2|pass2|
@test
Examples:
|userValue|passValue|
|user3|pass3|
|user4|pass4|
@live
Examples:
|userValue|passValue|
|user5|pass5|
|user6|pass6|
运行测试用户的Runner类。相应地改变其他两个。我在Java中提到过你需要改变量角器。
@CucumberOptions(tags = { "@test" }, plugin = {""}
glue = "", features = "")
答案 1 :(得分:0)
我对您为什么要测试可以登录三种不同环境感兴趣。通常在测试时,您将在尝试登录之前创建帐户。因此,在测试环境中,您将从一个空数据库开始,您的方案将是
Given I am registered
When I sign in
Then I should be signed in
Given
创建帐户,When
使用该帐户登录,Then
检查用户界面也确认您已登录。
我不知道您为什么要在开发环境中运行此方案。
我可以看到您可能想要测试生产系统上是否有某些帐户,但这与测试您可以登录的情况完全不同。同时针对生产环境运行方案也很危险。因此,如果你仍然想要这样做,我会坚持你使用一个单独的场景(理想情况下是完全独立的一组功能),因为你真的在测试不同的东西
Scenario: Accounts exist on production
...
Scneario: I can login
...