4

I am developing an hexagonal application with BDD approach with Specflow (C# cucumber).

I want to implement automated scenario system test running the core and injecting test double on the port of the inner hexagon instead of the production adapters.

I am also using composition-root pattern, and that means that the core dependencies are resolved outside the core: that already smells to me (it is correct to resolve the dependencies of the core towards the outer hexagon injecting the adapters, but what about the internal dependencies of the core?).

Usually test classes resolve dependencies their way, injecting test double, but now they must be able to assemble core too. So now we do not have a single point of truth in resolving the dependencies of the core, cause the test must copy the composition root and if production composition root replace an internal service of the core modifying and breaking its behaviour, the automated test remain green, cause the test composition root still inject the old implementation of the service.

What is the correct solution to this issue? Thanks

Rob80
  • 55
  • 1
  • 4

1 Answers1

0

Take a look at Chapter 26 ("The Main Component") of the book "Clean Architecture - A Craftman's Guide to Software Structure and Design", by Robert C. Martin.

The Main Component depends on all other components of the app, it is the entry point of the app, and it's here where the composition root lives. It creates the whole app and runs it with a certain configuration. You have a Main for each configuration.

choquero70
  • 3,332
  • 2
  • 24
  • 40