我有一个带有标签的后台测试用例,我需要每次在多场景下运行。
示例:
有3种情况和1种背景。简而言之,Background的行为应类似于@BeforeMethod的测试
所以我的处决应该像
- 然后是场景1(@ Dev,@ tagteacher1)
- 先获得背景,然后再获得场景2(@ Dev,@ tagteacher2)
- 先获得背景,然后再获得方案3(@ Dev,@ tagteacher3)
@TestStory
Feature: Teachers' timesheet need to be filled
Background:
Scenario Outline: Open Webpage
Given User Open teacher application with given <ENDPOINT>
And Login into application with given <USERNAME> and <PASSWORD>
And User clicks on teacher submission link
@DEV
Examples:
| endpoint | USERNAME | PASSWORD |
| http://teachersheetdev.ggn.com | sdrdev| aknewdev|
@QA
Examples:
| endpoint | USERNAME | PASSWORD |
| http://teachersheetqa.ggn.com | sdrqa | aknewdev|
@tagteacher1
Scenario1: Open app home page and click the button1
Given I'm at the teachersheet homepage
When User clicks Add Task button
Then User should see the tasks schedule
@tagteacher2
Scenario1: Open app home page and click the button2
Given I'm at the teachersheet homepage
When User clicks Add Task button
Then User should see the tasks schedule
@tagteacher3
Scenario1: Open app home page and click the button3
Given I'm at the teachersheet homepage
When User clicks Add Task button
Then User should see the tasks schedule
import org.junit.runner.RunWith;
import com.optum.synergy.common.ui.controller.WebController;
import cucumber.api.CucumberOptions;
import cucumber.api.SnippetType;
import cucumber.api.junit.Cucumber;
@RunWith(Cucumber.class)
@CucumberOptions(
plugin = { "json:target/test_results/cucumber.json"},
features = { "src/main/resources/ui/features" },
tags ={"@Dev,@tagteacher"},
snippets = SnippetType.CAMELCASE
)
public class CucumberRunnerTest {
public static void tearDown(){
WebController.closeDeviceDriver();
}
}
当我想与Dev或QA env一起运行时如何使用标签?
答案 0 :(得分:0)
通过在配置中设置您正在使用的站点,您将能够更轻松地实现这一目标 文件(无论是开发站点还是质量保证站点),然后使用与质量检查或开发相关的用户名和密码移动到步骤定义。
在此之后,您将可以执行以下操作:
Background:
Given the user has opened the teachers application
And they have logged in
@teacher
Scenario: Open app home page and view the task schedule
Given they are on the teachersheet homepage
When they start to add a task
Then they should see the task schedule
@teacher
Scenario: Open app home page and view the task schedule
Given they are on the teachersheet homepage
When they start to add a task
Then they should see the task schedule
如果您需要以其他老师的身份登录,则必须将登录步骤移至“方案”中,因为它们将不相同,并且您必须提供有关登录者的详细信息。< / p>
作为旁注,请考虑您使用的措辞。如果要测试站点的设计,单击按钮会很好,但是使用Cucumber的主要原因是表达意图-描述用户应该如何浏览站点,而不必担心实现细节。这是为了弥合业务与开发团队之间的沟通鸿沟,以便他们可以确定正在测试哪些方案。实施细节隐藏了测试的意图。