Using Test-Driven in DDD (Domain layer)

3.2k Views Asked by At

How to start with TDD in Domain layer, and what I mean by this is how to test Domain Models?

What is it that should be tested? the Aggregates or each Entity ?

What are some good practices and strategies for testing the onion architecture Domain layer ?

1

There are 1 best solutions below

2
On BEST ANSWER

Here is a very good example of Vaughn Vernon on how to test the Domain Model:

https://github.com/VaughnVernon/IDDD_Samples/tree/master/iddd_collaboration/src/test/java/com/saasovation/collaboration

Check the subpackage, each packages test a layer of the onion architecture:

  • the application layer,
  • the domain layer,
  • the infrastructure layer

On the domain model tests, each components are tested: aggregates for their methods, entities and even value objects.

He is the author of the book Implementing Domain Driven Design, and he writes examples in java and C#. He is recognized for his work in the DDD community and his work promotes good practices. I suggest you to also read his book to learn more about this fascinating subject.