Thank you for your answer. That was not quite what I was looking for. Maybe with a use case would be better: imagine that you have a web page with a form with 3 fields (A, B, C) and a table with columns A, B and C, that correspond to the form fields. When you fill the form and submit it, a line in the table is added, with the values that you filled in the form. Suppose I'm interested in testing this mechanism of submitting the form and seeing the new values in the table. A possible scenario could be:
Given I am in the table page When I fill all the fields And submit the form Then I should see, in the table, a new line with the new values For the sake of idempotence of the test, I generate random values to fill the form. So, in the "Then" step, I have to know what were the values introduced in the "When I fill all the fields" step. In cucumber, you can set 3 variables in the "World" object, each one with the value of a field in the form. Then, I can use the variables/values in the "Then" step of the scenario to make the assertion. Also, I don't have to worry about these variables passing to other scenarios, because they are "cleaned" (they are removed from the "World" object) when the scenario ends. How can I achieve this in JBehave? Thank you in advance, Bernardo Oliveira Pinto On Mon, Dec 23, 2013 at 5:20 PM, Mauro Talevi <[email protected]>wrote: > Hi, > > if you want to share values between steps in different classes, you can > inject your own context class - a simple pojo or some other API class - and > autowire it using one of the DI containers that are supported, Spring, > Guice, Pico etc ... If you declare this class as a singleton in the > container (the default in most containers), it'll allow you share its > values. > > I hope that helps. If it doesn't feel free to share your use case and > what you are trying to do via an example. > > Cheers > > > On 23/12/2013 01:25, Bernardo Pinto wrote: > >> Hi, >> >> I want to save the value of some variables from one step to the following >> ones. >> I found this thread on the subject: http://www.mail-archive.com/ >> [email protected]/msg00719.html. >> What I wanted to know is if JBehave still does not have a mechanism to >> store the state of a Scenario (as, for example, Cucumber: >> https://relishapp.com/cucumber/cucumber-tck/docs/world-or-context). >> If this mechanism still does not exist, do you have any suggestion about >> how should I do this? >> >> Thank you in advance, >> Bernardo Oliveira Pinto >> > > > --------------------------------------------------------------------- > To unsubscribe from this list, please visit: > > http://xircles.codehaus.org/manage_email > > >
