Hi Hans,
JBehave supports this via GivenStories:
http://jbehave.org/reference/stable/given-stories.html
Note that it's up to you to implement the logic to determine if the
given story (or scenarios therein) should be re-executed.
Cheers
On 11/09/2013 14:08, Hans Schwäbli wrote:
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.