Neema Cheriyath
2009-Apr-27 04:44 UTC
[rspec-users] Cucumber: Setting Dependency among scenarios
Hi,
I am planning to use cucumber-java for my java project for automated
testing. I would like to know if there is any option in cucumber, by
which we can explicitly provide dependency among running scenarios. For
example:
I have a ValidateProfile.java and a ProfileSignIn.java.
public class ValidateProfile {
...
public ValidatedProfile validate(String userName, String password) {
...
...
}
}
public class ProfileSignIn {
public void doSignIn(ValidatedProfile profile) {
...
...
}
}
Suppose I have a step definition for ValidateProfile as:
public class ValidateProfileTest {
@Given("I have user credential as (.*) and (.*)$")
public void setCredentials(String userName, String password) {
// set credentials to members
...
}
@When("I call Validate Profile")
public void validateProfile() {
...
ValidatedProfile profile = validateProfile.validate(_userName,
_password);
// set profile in class member
...
}
@Then("Profile should validate successfully() {
// assert contents of Validated Profile
}
}
Now I would like to create a Test case, say ProfileSignInTest, for
ProfileSignIn. As ProfileSignIn requires a ValidatedProfile, I would
like to run ValidateProfileTest prior to that and make use of the
ValidatedProfile as input to ProfileSignInTest.
Before running a scenario in ProfileSignInTest''s feature(say
profilesignin.feature) , Is there any option to run the features of
ValidateProfileTest(say validateprofile.feature), get its output and
pass the same as input to profilesignin.feature ''s scenario as below:
validateprofile.feature
-----------------------
@getValidatedProfiles
Given I have a username and password
When I call Validate Profile
Then Profile should validate successfully
profilesignin.feature
---------------------
@profilesignin
use output as validatedProfile from @getValidatedProfiles
Given I have the validated profile as validatedProfile
When I call SignIn
Then I should get Signed In successfully
My idea is to make use of hooks as below, and if possible pass the
output of @getValidatedProfiles to the ''Given'' of
@profilesSignin. If
that''s not possible, I can make use of a java framework to store and
retrieve the output, but the priority is to make a scenario dependent on
one or more other scenarios.
Before(''@profilesignin'') do
//run the scenario with tag @getValidatedProfiles
end
Other than hooks, If there are any other better ways of handling
this, please let me know.
Thanks,
Neema
--
Posted via http://www.ruby-forum.com/.
Neema Cheriyath
2009-Apr-29 09:10 UTC
[rspec-users] Cucumber: Setting Dependency among scenarios
Thank you Aslak. Let me see whether I can make use of Background for implementing the dependency issue that I mentioned. I think implementing hooks in cucumber_java will be useful for us, since we can make use of that to get a detailed report with all the required information while running the scenarios in cucumber. I will create a ticket to implement hooks in cucumber_java. Thanks, Neema -- Posted via http://www.ruby-forum.com/.
Neema Cheriyath
2009-Apr-29 09:34 UTC
[rspec-users] Cucumber: Setting Dependency among scenarios
Hi Aslak,
I have created a new ticket in github for implementing hooks
in cucumber_java. Please find the link:
http://github.com/aslakhellesoy/cucumber_java/issues/#issue/2
Thanks,
Neema
--
Posted via http://www.ruby-forum.com/.