The best practice is indeed that of a context object, but you need to define it yourself depending on the DI framework you use.
> On 1 Oct 2015, at 18:55, Alex Filatau <[email protected]> wrote: > > Hi, > > I'm looking for recommended solution (best practices) on sharing test data > (strings, Json Objects, POJO - anything) between steps, especially when they > located in different classes. Let's consider following abstract example: > > Given I am a user with '2' cars > When I'm logged in > Then I should see '2' cars on Home screen > > This case represents two approaches in sharing some test data between steps: > assuming that '2' is a variable - I pass this test data as parameter from > actual scenario into 2 step implementations. There is no problem with that, > looks good and reusable > but second step needs to know something that was defined in the previous > (first) step, login credentials to be specific > This last case is what I'm trying to ask about. First step does some mages > about creating user and it needs to communicate credentials to any other step > that might need them. If first and second steps implementations are in the > same class - well, we can use some instance or class variables to store that. > But it's not always the case, and this information might be needed somewhere > else outside of this class. > > So what is the best practices to share such data given that propagate it > through stories is not an option (it might be result for some calculations > after all, not just an email) and given that Jbehave AFAIK does not have any > object like "context" or "world" in Cucumber? > > The implementations we consider now are Enum Singleton or static class > wrapping around hash map, I got suggestions to look into ThreadLocal as well, > but would love to learn about experiences. > > -- > You received this message because you are subscribed to the Google Groups > "JBehave User" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > To view this discussion on the web, visit > https://groups.google.com/d/msgid/jbehave-user/64f18407-6e84-4e88-ab75-748baada94ce%40googlegroups.com. > For more options, visit https://groups.google.com/d/optout. -- You received this message because you are subscribed to the Google Groups "JBehave User" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send an email to [email protected]. To view this discussion on the web, visit https://groups.google.com/d/msgid/jbehave-user/D258D880-5E6A-4321-964D-F0919ABB4F35%40aquilonia.org. For more options, visit https://groups.google.com/d/optout.
