O'Reilly logo

The Cucumber for Java Book by Seb Rose, Matt Wynne, Aslak Hellesoy

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Improving Our Design Using DI

As we’ve seen, DI can make our lives simpler by doing some of our work for us. At the moment our application is using DI to share some state, but code in KnowsTheDomain is managing the creation of quite a few domain entities. As our application grows, we’re likely to find more domain entities that need to be shared between our step definitions. The temptation would be to put all our shared domain entities into KnowsTheDomain, but this would soon grow huge, exhibiting the Monster Object antipattern.[54]

To keep our step definitions maintainable, it’s a good idea to create a step definition class for each domain entity. It’s clear that the Cash Slot step definition is going to need to interact with the Cash Slot ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required