国内有哪些比较好的刷题网站站

php - Scenario vs. Scenario Outline - Stack Overflow
to customize your list.
Join the Stack Overflow Community
Stack Overflow is a community of 6.6 million programmers, just like you, helping each other.
J it only takes a minute:
Background:
I'm currently writing behat tests (Mink/Selenium) for a Symfony2 webpage. I have a good deal of examples to go by, and actually writing them should be no problem. The step definitions are already written.
However, in the examples, they some times define a Scenario: and some times a Scenario Outline:
What is the difference between these two ways of defining a test?
29.5k96887
Copying and pasting scenarios to use different values can quickly become tedious and repetitive:
Scenario: Eat 5 out of 12
Given there are 12 cucumbers
When I eat 5 cucumbers
Then I should have 7 cucumbers
Scenario: Eat 5 out of 20
Given there are 20 cucumbers
When I eat 5 cucumbers
Then I should have 15 cucumbers
Scenario Outlines allow us to more concisely express these examples through the use of a template with placeholders
Scenario Outline: Eating
Given there are &start& cucumbers
When I eat &eat& cucumbers
Then I should have &left& cucumbers
| start | eat | left |
The Scenario Outline steps provide a template which is never directly run. A Scenario Outline is run once for each row in the Examples section beneath it (except for the first header row).
More in the
24.4k65491
Scenario is what it is.
Scenario outline uses placeholders for faster testing.
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
rev .24780
Stack Overflow works best with JavaScript enabledpython - How to implement a scenario outline in lettuce using pycharm - Stack Overflow
to customize your list.
Join the Stack Overflow Community
Stack Overflow is a community of 6.6 million programmers, just like you, helping each other.
J it only takes a minute:
I have the following feature:
Feature: Check if the weather service works properly
In order to check the weather service
As beginner
I'll get some values and check if they are ok and if the temperature given is correct
Scenario: Check if a city and and country given are correct
Given I access the url with http://api.openweathermap.org/data/2.5/weather
And the city is &city& and the country &country&
When I ask for the city and country name
Then I check if the city and country are correct
And I check if the status code is 200
| country |
| Barcelona | ES
And I have the following step:
@step("the city is (.*) and the country (.*)")
def city_and_country(self, expectedCity, expectedCountry):
world.expectedCity = expectedCity
world.expectedCountry = expectedCountry
but when I execute this step I have the followin information:
I check the lettuce documentation and the scenario outline looks pretty well, but I still don?t understand what I'm doing wrong. Any ideas?
Thanks in advance!
I just found the answer to my own question:
Scenario Outline: Check if a city and and country given are correct
Given I access the url with http://api.openweathermap.org/data/2.5/weather
And the city is &city& and the country &country&
When I ask for the city and country name
Then I check if the city and country are correct
And I check if the status code is 200
| country |
| Barcelona | ES
And the step definition is:
@step('the city is ([^"]+) and the country ([^"]+)')
def city_and_country(self, expectedCity, expectedCountry):
world.expectedCity = expectedCity
world.expectedCountry = expectedCountry
Hope it helps in a future!
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
rev .24780
Stack Overflow works best with JavaScript enabledc# - SpecFlow: Scenario Outline Examples - Stack Overflow
to customize your list.
Join the Stack Overflow Community
Stack Overflow is a community of 6.6 million programmers, just like you, helping each other.
J it only takes a minute:
I just starting to work with SpecFlow and really like the tool.
However I am running across some issues in relation to example data inputs into the Scenario Outlines.
Just wondering if what I am facing is normal or whether there is a trick to it.
I am using C# Visual Studio 2013 and writing an MVC App using the underscore style of step definition.
I have also tried the regular expression style but still get similar issues.
So the issue is I am providing username, password etc as parameters and including sample data in my Examples.
It appears that the following occurs: -
I have to put "" around the parameters when 1st generating the scenario, otherwise it does not get picked up as a parameter at all.
However when passing data in from the examples I get a "/" at the end of the data passed in.
When I go back to the scenario I then remove the "" around the parameter.
This is a little frustrating but if that is the best way to handle it I can live with that.
Just wondering if anyone has any advice on this point.
The next issue is related to the data itself.
It appears if I have any characters such as @ or & etc in my data, then it splits that data at that point and feeds it to the next parameter so I get incorrect data being fed through.
I have included my code below - if anyone has any suggestions or resources to look at that would be appreciated.
Feature File
Feature: AccountRegistration
In order to use Mojito services in my organisation
As a guest user
I want to create an account with administration privelages
Scenario Outline: Register with valid details
Given I am on the registration page
And I have completed the form with &email& &organisation& &password& and &passwordConfirmation&
When I have clicked on the register button
Then I will be logged in as &username&
And my account will be assigned the role of &role&
| organisation | password
| passwordConfirmation | username
| usernamea | Bytes
| password1 | password1
| usernamea | Admin |
| usernameb | Bytes
| password2 | password2
| usernameb | Admin |
| usernamec | Bytes
| password3 | password3
| usernamec | Admin |
| usernamed | Bytes
| password4 | password4
| usernamed | Admin |
| usernamee | Bytes
| password5 | password5
| usernamee | Admin |
Scenario Outline: Register with invalid details
Given I am on the registration page
And I have completed the form with &email& &organisation& &password& and &passwordConfirmation&
When I have clicked on the register button
Then I will get an error message
| organisation
| password
| passwordConfirmation |
| 1LTIuta&Sc | wrongpassword
| 1LTIuta&Sc | 1LTIuta&Sc
| No Organisation | 1LTIuta&Sc | 1LTIuta&Sc
Steps Generated File
public class AccountRegistrationSteps
public void Given_I_am_on_the_registration_page()
ScenarioContext.Current.Pending();
public void Given_I_have_completed_the_form_with_usernamea_Bytes_password_P0_and_password_P1(int p0, int p1)
ScenarioContext.Current.Pending();
public void Given_I_have_completed_the_form_with_Jonesa_mojito_com_Bytes_P0_LTIuta_Sc_and_wrongpassword(int p0)
ScenarioContext.Current.Pending();
public void When_I_have_clicked_on_the_register_button()
ScenarioContext.Current.Pending();
public void Then_I_will_be_logged_in_as_usernamea()
ScenarioContext.Current.Pending();
public void Then_my_account_will_be_assigned_the_role_of_Admin()
ScenarioContext.Current.Pending();
public void Then_I_will_get_an_error_message()
ScenarioContext.Current.Pending();
SpecFlow does handle string parameters by default, the problem is that you left control up to SpecFlow in determining at runtime what your values are.
When you ran "Generate Step Definitions," you selected "Method name - underscores" in the Style dropdown. This left interpreting the input parameters up to SpecFlow, which will create what are called 'greedy' regular expressions to identify the parameter values. This means that it would include the comma as part of the value.
Had you selected "Regular expressions in attributes," (or refactored your code a touch and decorated your attributes by hand) your step could look like this:
[Given(@"I have completed the form with (.*), (.*), (.*), and (.*)")]
public void Given_I_have_completed_the_form_with(string email, string org, string pwd, string conf)
//do stuff here
This creates a more 'parsimonious' expression that tells SpecFlow to accept strings of any length, up to but not including any trailing commas. Single quotes around the regular expressions would make it even more explicit:
[Given(@"I have completed the form with '(.*)', '(.*)', '(.*)', and '(.*)'")]
Managing the regular expressions yourself can create headaches, but it really exposes the full power of SpecFlow if you do so.
RESOLVED - It was not an issue with the use of characters such as @ or &.
It was actually using commas in my Given Statement.
I found if I used 'and' it works.
So to get it working the statement had to be written as below: -
Write statement as
Given I have completed the form with &email& and &organisation& and &password& and &passwordConfirmation&
Modify statement to put single quotes around paramaters that need to be strings
Given I have completed the form with '&email&' and '&organisation&' and '&password&' and '&passwordConfirmation&'
Generation Step Definitions and then change statement back to exclude single quotes
Given I have completed the form with &email& and &organisation& and &password& and &passwordConfirmation&
A bit of mucking around but it gets the correct results.
Hopefully in the future SpecFlow will be updated to handle paramaters as strings as default.
5,62332142
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
rev .24780
Stack Overflow works best with JavaScript enabledautomated tests - Cucumber tags for scenario outline examples - Stack Overflow
to customize your list.
Join the Stack Overflow Community
Stack Overflow is a community of 6.6 million programmers, just like you, helping each other.
J it only takes a minute:
In the project I am currently working we are using cucumber for integration testing and to keep the regular daily builds from getting too big we use profiles using tags to have a smaller daily test and a larger weekly build test suite.
Now I have a scenario outline with example inputs that I want to split up so that one example is in the daily build and others in the weekly.
Something in the spirit of
Scenario Outline: Doing some tests
Given a step
When I do some &input&
Then I should get some &output&
|daily 2 o |
|week 999 o|
Is this possible in any way? Should it be? Or is it a dumb idea to do it this way?
After some research I found out that this is already supported from out of the box. You just have to add two Example headers to the test. Using my own example from the question to illustrate
Scenario Outline: Doing some tests
Given a step
When I do some &input&
Then I should get some &output&
|daily 2 o |
|week 999 o|
Have you tried using a Before hook for an Example? It doesn't work for me, it may be a bug or feature.
Scenario Outline: Doing some tests
Given a step
When I do some &input&
Then I should get some &output&
|daily 2 o |
Before('@daily') do
p "before daily"
Nothing happens. It seems that cucumber doesn't know about Before examples. Using Ruby Cucumber 1.3.10
I'm sitting in a debugger, in an 'after scenario' hook, with 'scenario' showing as a Cucumber:Ast:OutlineTable::ExampleRow and 'scenario.source_tag_names' returns the feature tags and the scenario outline tags.
Rooting around in the object directly, although I can easily find the table and cells references, I can't even locate the example table's tags by force.
We're successfully using tags on the example tables to filter them in and out (per the accepted answer), so Cucumber obviously sees them for that purpose, but that's all those tags appear to be available for - not for hooks, and not for observing from hooks.
Seems a bit inconsistent to me.
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
rev .24780
Stack Overflow works best with JavaScript enabledpython 2.7 - How to run Scenario Outline in PyCharm 4 with Lettuce runner - Stack Overflow
to customize your list.
Join the Stack Overflow Community
Stack Overflow is a community of 6.6 million programmers, just like you, helping each other.
J it only takes a minute:
I have simple feature:
Feature: Lol and other words
Scenario: Lol printing
Given I like print "lol"
Scenario Outline: Words printing
Given I like print "&word&"
And implementation:
from lettuce import step
@step('I like print "([^"]+)"')
def step_impl(step, word):
print word
When PyCharm lettuce test runner execute feature its run first scenario without problems but second is never executed (however it knows that there is other scenario) - so it looks like:
How to run Scenario Outline with this runner?
Windows 8.1, PyCharm 4.0.1 139.556 EAP Professional, lettuce 0.2.20, Python27
5,18963960
This is bug and it is reported to JetBrains team:
5,18963960
Your Answer
Sign up or
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Post as a guest
By posting your answer, you agree to the
Not the answer you're looking for?
Browse other questions tagged
rev .24780
Stack Overflow works best with JavaScript enabled}

我要回帖

更多关于 程序员刷题网站 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信