I want to write the following type of scenario, which if you picture
it behind the scenes
is building up a task which is then to be run before returning
results.
When I search for x
With a filter of x
And a filter of x
Then I receive results containing y
A number of problems:
1) the With keyword does'nt exist, but I read somewhere that Gherkin
supports aliasing, so this is
something I might look into.
2) If I'm building up a search request in this way, what I have is
that the first three steps
implicitly translate to one transaction behind the scenes (an HTTP
request). Is what I'm
testing at fault, or do I need to simple rephrase what I'm trying to
test.
e.g:
When I want to search for a list of 'x'
And I use a keyphrase of 'keyphrase'
And a filter of 'filter1'
And a filter of 'filter2'
And I submit my search to 'server'
Then I should receive results containing y
What would be going on in terms of implementation details, is that the
first 4 steps would
be building a query request ( e.g an HTTP query string ), and step 5
would essentially forward
the request to the search server.
This seems to work and read better, but I'm not sure if its the sort
of thing I should be doing with gherkin?
On Saturday, February 25, 2012 at 10:07 PM, mswinson wrote:
> Hi,
> I want to write the following type of scenario, which if you picture > it behind the scenes > is building up a task which is then to be run before returning > results.
> When I search for x > With a filter of x > And a filter of x > Then I receive results containing y
> A number of problems: > 1) the With keyword does'nt exist, but I read somewhere that Gherkin > supports aliasing, so this is > something I might look into. > 2) If I'm building up a search request in this way, what I have is > that the first three steps > implicitly translate to one transaction behind the scenes (an HTTP > request). Is what I'm > testing at fault, or do I need to simple rephrase what I'm trying to > test.
> e.g:
> When I want to search for a list of 'x' > And I use a keyphrase of 'keyphrase' > And a filter of 'filter1' > And a filter of 'filter2' > And I submit my search to 'server' > Then I should receive results containing y
> What would be going on in terms of implementation details, is that the > first 4 steps would > be building a query request ( e.g an HTTP query string ), and step 5 > would essentially forward > the request to the search server.
> This seems to work and read better, but I'm not sure if its the sort > of thing I should be doing with gherkin?
> Mark
> -- > You received this message because you are subscribed to the Google Groups "Cukes" group. > To post to this group, send email to cukes@googlegroups.com (mailto:cukes@googlegroups.com). > To unsubscribe from this group, send email to cukes+unsubscribe@googlegroups.com (mailto:cukes+unsubscribe@googlegroups.com). > For more options, visit this group at http://groups.google.com/group/cukes?hl=en.
> I want to write the following type of scenario, which if you picture > it behind the scenes > is building up a task which is then to be run before returning > results.
> When I search for x > With a filter of x > And a filter of x > Then I receive results containing y
> A number of problems: > 1) the With keyword does'nt exist, but I read somewhere that Gherkin > supports aliasing, so this is > something I might look into. > 2) If I'm building up a search request in this way, what I have is > that the first three steps > implicitly translate to one transaction behind the scenes (an HTTP > request). Is what I'm > testing at fault, or do I need to simple rephrase what I'm trying to > test.
> e.g:
> When I want to search for a list of 'x' > And I use a keyphrase of 'keyphrase' > And a filter of 'filter1' > And a filter of 'filter2' > And I submit my search to 'server' > Then I should receive results containing y
> What would be going on in terms of implementation details, is that the > first 4 steps would > be building a query request ( e.g an HTTP query string ), and step 5 > would essentially forward > the request to the search server.
> This seems to work and read better, but I'm not sure if its the sort > of thing I should be doing with gherkin?
> Mark
Fundamentally gherkin is about expressing business needs, not about listing implementation details. What you should do is find a name for x with a filter of x and x. Then you can just have
When I search for foo Then I should see results for foo
This is just so much easier to implement, and the feature has less noise. All the detail about the filters is delegated down to the step definitions, and ideally down to your actual source. For example if this was a Rails app you would use foo to define a scope and then have you search use the scope. Now instead of having the scope defined in two places (the text of your feature and you source) you are only using the definition in your code.
If you really want to assemble something in gherkin then you can communicate between steps in a number of ways
1) Use a variable e.g @search 2) Put something in a database and then retrieve it using last in subsequent steps e.g. Search.last (this relies on the database being emptied between scenarios) 3) Identify the thing in the feature and then use the id to retrieve e.g. When I create a foo search, And I add a filter to foo and then Search.find('foo') in subsequent steps
Variables can be very elegant, especially for feature text but their overuse can quickly cause chaos (their globals after all) Using last is fine, until you add something else into the database by mistake e.g. using a related factory with a side effect Using an identity is safest but uglifies your features
> -- > You received this message because you are subscribed to the Google Groups > "Cukes" group. > To post to this group, send email to cukes@googlegroups.com. > To unsubscribe from this group, send email to > cukes+unsubscribe@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/cukes?hl=en.
-- ------------------------ Andrew Premdas blog.andrew.premdas.org