Maven 每次测试都会运行标记的挂钩
我的课程如下:Maven 每次测试都会运行标记的挂钩,maven,selenium,cucumber,cucumber-java,cucumber-junit,Maven,Selenium,Cucumber,Cucumber Java,Cucumber Junit,我的课程如下: @Before("@Firefox") public void setUpFirefox() {} @Before("@Chrome") public void setUpChrome() {} @After public void tearDown(){} 当我运行以下命令时,mvn test-Dcucumber.options=“--tags@Chrome”两个@Before函数都在调用 如何根据maven命令运行特定的@Before方法? 我的Runner类(我已经尝
@Before("@Firefox")
public void setUpFirefox() {}
@Before("@Chrome")
public void setUpChrome() {}
@After
public void tearDown(){}
当我运行以下命令时,mvn test-Dcucumber.options=“--tags@Chrome”
两个@Before
函数都在调用
如何根据maven命令运行特定的@Before
方法?
我的Runner类(我已经尝试了标记
选项,它对我也不起作用):
我的功能文件:
Feature: Storybook
@Test @Widgets @Smoke @Chrome @Firefox
Scenario: Storybook example
Given The user clicks on "storybook" index on the homepage
And Storybook HomePage should be displayed
看起来这是因为您已经为该场景设置了两个标记,before钩子似乎是根据正在运行的场景执行的。e、 g -tag命令行--tags@Chrome等指定要运行的场景 -现在,基于该场景,使用附加到该场景的标记(测试、小部件、Smoke、Chrome、Firefox)执行before函数 如果你有一个标签烟雾的前钩子,我想它也会运行 例如: (在斯卡拉) 在(“@test1”)之前{code=> println(“采取行动前的测试1”) } 在(“@test2”)之前{} println(“采取行动前的测试2”) } 使用功能文件:
[...]
@test1
Scenario: Test scenario 1
Given Some precondition occurs
@test2
Scenario: Test scenario 2
Given Some precondition occurs
当我运行这些标记中的任何一个时,我都会得到输出
test1在执行操作之前
或test2在执行操作之前
但是,如果在一个场景中同时使用两个标记,则会打印两行
在那些setupChome、setupFirefox函数中,只需设置驱动程序,就可以执行什么操作?您可以创建新的系统属性,例如browser
,匹配值并执行一些设置,然后您可以键入:
-Dbrowser=chrome
并且它会以这种方式进行设置。看起来这是因为您已经为该场景设置了两个标记,before钩子似乎是根据正在运行的场景执行的。e、 g
-tag命令行--tags@Chrome等指定要运行的场景
-现在,基于该场景,使用附加到该场景的标记(测试、小部件、Smoke、Chrome、Firefox)执行before函数
如果你有一个标签烟雾的前钩子,我想它也会运行
例如:
(在斯卡拉)
在(“@test1”)之前{code=>
println(“采取行动前的测试1”)
}
在(“@test2”)之前{}
println(“采取行动前的测试2”)
}
使用功能文件:
[...]
@test1
Scenario: Test scenario 1
Given Some precondition occurs
@test2
Scenario: Test scenario 2
Given Some precondition occurs
当我运行这些标记中的任何一个时,我都会得到输出
test1在执行操作之前
或test2在执行操作之前
但是,如果在一个场景中同时使用两个标记,则会打印两行
在那些setupChome、setupFirefox函数中,只需设置驱动程序,就可以执行什么操作?您可以创建新的系统属性,例如browser
,匹配值并执行一些设置,然后您可以键入:
-Dbrowser=chrome
,它会以这种方式进行设置