Java 运行Cumber测试更改变量?
请允许我向您展示我在学校平台上进行的测试中的一小段代码:Java 运行Cumber测试更改变量?,java,selenium,cucumber,Java,Selenium,Cucumber,请允许我向您展示我在学校平台上进行的测试中的一小段代码: Background: I Enter the school page In Schools I navigate to: | Hierarchical level | Action | Value | | District | expand | District-A | | School |
Background:
I Enter the school page
In Schools I navigate to:
| Hierarchical level | Action | Value |
| District | expand | District-A |
| School | right click | Saint John's |
And Choose "Go to" on the Popup Menu
And Zoom In To See More Options in Control Bar
你看,我用这个背景在网站上的一棵小树上导航。
我这里的问题是,我可以不让District-A和Saint John's有两个变量,比如District和school,这样当我在命令行上运行测试时,有一个额外的参数:我希望这轮测试将我的学区设为B区,并将学校变量设为其中一所学校。
首先,这可能吗?
第二,如果是,有人能给我一个快速的想法,我如何可以做到这一点
提前非常感谢-在cucumber中,您可以编写场景来描述您正在尝试做的事情,也许还可以解释为什么它很重要。你不应该写一些步骤来解释你是怎么做的。任何涉及单击、扩展等的步骤最终都会导致您遇到的问题 因此,第一件事是描述这个背景试图实现什么,以及为什么它很重要。之后,思考如何将其下推到步骤定义和帮助器方法中。这样做之后,你可能会得到这样的结果
Scenario: View a school
Given there is a school
When I view the school
Then I should see the school
Feature: Search for a school
We want to be able to find a particular school
Scenario: Find a school
Given there are lots of schools with one searchable
When I search for the school
Then I should see search results with one school
这看起来很简单,但这就是重点。你应该使你的网站简单易用。所以你需要做的第一件事就是能够看到一所学校。在你有了这个之后,你可能想和很多学校打交道,考虑找一所特殊的学校。然后你可能会得到这样的结果
Scenario: View a school
Given there is a school
When I view the school
Then I should see the school
Feature: Search for a school
We want to be able to find a particular school
Scenario: Find a school
Given there are lots of schools with one searchable
When I search for the school
Then I should see search results with one school
你可以采取类似的措施
Feature: Districts
Schools are organised by districts. We would like to view all the schools in a district
Scenario: View district
Given there is a district
When I view the district
Then I should see the district
Scenario: See schools in a district
Given there is a district
And the district has some schools
When I view the district
Then I should see some schools
等等
请注意,这些场景中没有任何一个与页面、单击等相关的内容。这都是什么以及为什么不是如何。还要注意每件事都是多么简单