Unfortunately there seems to be a bug concerning GivenStories in 4.0-beta-3. It did not work with that version. But it works with JBehave 3.8.0.
2013/9/12 Hans Schwäbli <[email protected]> > Great, thank you for that answer. > > I was looking for something like "Given Scenario", but this is not the > JBehave concept as it seems. > > The scenarios seem not to be intended to be independent from each other. > They seem to be run always in sequential order. > > So I can re-model this to achieve my goal and maybe I have to implement > logic to optimize execution. > > ---------- Forwarded message ---------- > From: Hans Schwäbli <[email protected]> > Date: 2013/9/11 > Subject: Transitive Scenarios > To: [email protected] > > > I am new with JBehave. When writing my first three login tests, I > discovered that they depend on each other. > > - Scenario 1 "Positive Login": User can login and is on homepage then. > - Scenario 2 "Positive Logout": User can logout successfully. > - Scenario 3 "Positive Re-Login": User can login after logout. > > Logically this can be modelled as dependencies: Scenario 3 depends on > scenario 2 which itself depends on scenario 1. To test all three scenarios > it would be enough to run just scenario 3. > > These are transitive scenarios, very much like transitive dependencies in > build tools like Maven. The application of transition differs (here tests, > there jar-files), but the topic is logically the same. > > So I thought, hey lets do it like this with JBehave: > > Scenario: Positive Logout > Given Positive Login > > But JBehave does not understand my intention with "Given Positive Login", > it prints a warning in the Eclipse editor. > > As it seems I could define combined steps and use them in the story. But > that would not be equivalent to be able to just write "Given Positive > Login" since the steps would not be documented in the story but in the > source code. > > Is this possible, to use "Given" in such a way that it refers to another > scenario in a story? If not, what do you think of that idea? > > I also wonder about declaring dependencies like in TestNG for scenarios, > so that test run execution time is optimized and the test result can be > easier analysed. > > If transitive scenarios are possible, JBehave could optimize the execution > time. So for instance only scenario 3 would be run (Positive Re-Login) and > since it refers to scenario 2 and scenario 2 refers to scenario 1, there > could also be results collected for all three scenarios. But does JBehave > work this way or can be made to work like it? > > My questions are not about re-using source code but re-using scenarios, > modelling scenarios by declaring transitive dependencies between them and > expecting that JBehave runs them in an optimized way, which means: no run > if dependent scenario failed or no run if already run as a dependency of > another scenario which already run. > > Its a bit complicated, but I hope you understand what I mean. > >
