Hi,
I had this kind of subject once in some project where I needed to test
web forms (CRUD).
Firstly I've tried to create only one story and one scenario for the
entire user interface and put all the input data possibilities as
example tables. (as you did)...
It get worst when I had to write the "THEN" steps... I had to put both
input and output on same row of the example table... more that 30 fields
on table !!
It get worst when I had to remember WHAT was being tested with that
combination of fields on that row of data !! :-(
So, my stories got unreadable for the business clients and got
unpractical to continue using example table like this.
The problem IMO, was that I was thinking more in reuse things (test
classes and user interfaces) than in the business scenario itself. :-s
So I decide to use some different approach...:
I've created one story for the UI crud and later lots of meaningfull
scenarios for it. one example could be:
Story: Creating bank account for customer
GivenStories: Config Metadata for Customer Interface !- as I need to
test interfaces, I need to inject fields names, types on steps classes...
Scenario: Employee should create an new customer and account
Meta:
@type Normal Process
Given that user is Authenticated
And user is on New Account page !- here your steps could get all the
names of field of your interface
When user enters the following Customer data:
|name|address|birthday|
|John Public| X street 300|16/01/1980|
And user enters the following Account data:
|type|initial deposit|
|investiment| 300000|
Then system should process, create the account and show this info:
|Resume|NextProcessStep|
|Ok| Thanks the customer|
Scenario: Customer needs have at least 18years
Meta:
@type BusinessRule
Given that user is Authenticated
And user is on New Account page
When user enters the following Customer data:
|name|address|birthday|
|Lady Kat| X street 300|16/01/1998|
And user enters the following Account data:
|type|initial deposit|
|saving| 1000|
Then system should process, do not create the account and show this info:
|Resume|NextProcessStep|
|NotOk - Customer is younger than needed. | Ask for the customer parents|
Well, some could say that I've writed much more, but I think I've gained
in readability. And my large reuse was concentrated only on the steps
classes. There you could use guice, pico or spring to help you fullfill
any info you wanted (as the interface meta data setted) from any source,
and could use any framework to test the UI. In my case, I've used selenium.
I've created steps like this:
@Given(user enters the following $entityName data: $entityDataTable")
public void theTraders(String entityName, ExamplesTable entityDataTable) {
Page mypage = bringMeThePage(entityName);
boolean result = mypage.fillPage(entityDataTable);
}
Inside fillPage() method I've used outcome tables to register each field
interaction (
http://jbehave.org/reference/stable/outcomes-table.html).
well, hope I had help.
cheers
Cristiano
On 02/12/10 14:56, Entfred wrote:
Hello,
I am curious if anyone has tried to do something like this:
Suppose you have
|fieldValue|field|
|John Public|name|
|Bob Smith|name|
|Sarah Pallen|name|
|Mr. Bill|name|
You would process your story with a line like this in your java:
@When("I type<fieldValue> into \"<field>\"")
This would correspond to the step
When I type<fieldValue> into name
This means, your story would run each line in the script four times -
one time for John Public, one time for Bob Smith.... one time for Mr. Bill.
Now, suppose you want to process multiple fields for each line?
If you tried the following, it would not work, since you would overwrite
your variables:
|fieldValue|field|fieldValue|field|
|John Public|name|50000.00|salary|
|Bob Smith|name|10000.00|salary|
|Sarah Pallen|name|999999.99|salary|
|Mr. Bill|name|10.54|salary
You could try and modify this to have
|fieldValue|field|fieldValue2|field2|
|John Public|name|50000.00|salary|
|Bob Smith|name|10000.00|salary|
|Sarah Pallen|name|999999.99|salary|
|Mr. Bill|name|10.54|salary
But, this is starting to get messy, since you would then need
@When("I type<fieldValue> into \"<field>\"")
in one method and
@When("I type<fieldValue2> into \"<field2>\"")
Has anyone run into this problem, before?
Thanks for any advice on this.
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email
---------------------------------------------------------------------
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email