[rspec-users] Cucumber: Setting Dependency among scenarios

Neema Cheriyath lists at ruby-forum.com
Mon Apr 27 00:44:10 EDT 2009

    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

    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,
    // 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:

    Given I have a username and password
    When I call Validate Profile
    Then Profile should validate successfully

    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

    Other than hooks, If there are any other better ways of handling
this, please let me know.

Posted via http://www.ruby-forum.com/.

More information about the rspec-users mailing list