Skip to content

Latest commit

 

History

History
27 lines (21 loc) · 749 Bytes

dependency-injection.md

File metadata and controls

27 lines (21 loc) · 749 Bytes
layout title
bootstrap
Dependency Injection

{{page.title}}

This is only relevant if you are using Cucumber-JVM with Java.

Java Step Definitions are annotated methods that live in a class:

{% highlight java %} public class BellyStepdefs { @Given("I have (\d+) cukes in my belly") public void cukesInTheBelly(int cukes) { // Do something with the cukes } } {% endhighlight %}

For each scenario, Cucumber will instantiate all classes that have glue code (Step Definitions or Hooks).

TODO

  • Describe why inheritance is bad
  • DI allows glue classes to share references to the same instances
  • Describe the different containers
  • Check the mailing list for common Q&A