Arpit,

Complementing Brian's answer, to maintain your tests at a functional level, You could do something like that:


Scenario: User with roleX should include a new information

Given that userX is logged and has roleX
And the selected feature is MyImportantFeatureWindowName
When user enter the following data:
|field1|field2|fieldN|
|value1|value2|valueN|
And ask to save the information
Then system returns the message: "data saved ok"


Inside your "Then" methods you could inclusive to access the database and certificate that the data is already saved...

 cheers

Cristiano

On 22/03/11 20:12, Brian Repko wrote:
Arpit,
Better yet - separate your concerns - I'm guessing that UI controls is probably not your system functionality...
@When("user $username logs in with password $password")
Keep your tests at the functional level - you can implement that as a service call or as a UI / Selenium functionality.
But don't lock your story into an architectural tier.
Brian
----- Original message -----
From: "Mauro Talevi" <[email protected]>
To: [email protected]
Date: Tue, 22 Mar 2011 23:03:20 +0000
Subject: Re: [jbehave-user] Query - parameterized stories
Why are you just parametrising one variable, and not both:

@When("user types \"$text\" in \"$objectId\"")

@Alias("user types <text1> in \"<objectId>\"")

publicvoiduserTypesData(|@Named("|text1|") |String text, @Named("objectId") String objectId)



On 22/03/2011 07:27, Arpit Sakhi wrote:

Hello,

I have query in creating parameterized stories. In my steps class I have a step

@When("user types \"$text\" in \"$objectId\"")

publicvoiduserTypesData(String text, String objectId){

seleniumLayer.textType(text,objectId);

}

I am using this step for every textbox data filling. E.g. my login story looks like –

When user types “[email protected] <mailto:[email protected]>” in "username"

When user types “pass1234” in "password"

When user clicks button "Login"

Now I want to make this login story as parameterized so that different stories can call login story with different credentials (usename and password).

To achieve this I have modified my login story as below –

When user types <text1> in "username"

When user types <text2> in "password"

When user clicks button "Login"

But to execute this I need to modify my java class too as below –

@When("user types \"$text\" in \"$objectId\"")

@Alias("user types <text1> in \"$objectId\"")

publicvoiduserTypesData(|@Named("|text1|") |String text, String objectId){

seleniumLayer.textType(text,objectId);

}

As per my understanding I need to write another method to handle the <text2> parameter. My query is there any way to use the same method again and again for different parameters (e.g. for text1 and text2). This is going to be a bigger issue if I am having 10-15 input boxes on my site and for all of them I want to pass parameters.

Any help or any suggestions on this?

Thanks in Advance

Arpit

DISCLAIMER ========== This e-mail may contain privileged and confidential information which is the property of Persistent Systems Ltd. It is intended only for the use of the individual or entity to which it is addressed. If you are not the intended recipient, you are not authorized to read, retain, copy, print, distribute or use this message. If you have received this communication in error, please notify the sender and delete all copies of this message. Persistent Systems Ltd. does not accept any liability for virus infected mails.

---
Brian Repko
LearnThinkCode, Inc. <http://www.learnthinkcode.com>
email: [email protected] <mailto:[email protected]>
phone: +1 612 229 6779

Reply via email to