Nice answer, I'd have gone the same way!
I always start test-driving the concrete interactors. And very often I
use other interactors to inspect system state. With this approach, the
acceptance layer of your test suite (the unit tests for your concrete
use cases) stays independent from entities.
I also use in-memory-implementations for the gateways, which makes my
tests blazing fast and they are simple to implement.
But I have a question, Frederik.
You say, that you don't specifically unit-test your entities, because
they merge from the use cases. I had the same urge probably one year ago
and tried it on smaller projects. Not on large ones, I don't wanted to
take the risk at this point.
My observations where, that this approach of testing feels nice at first
(as you said, entity refactorings for free), but leads to a problematic
state.
If your interactors use several entities, or an aggregate of several
entities, you quickly reach a state explosion and testing special edge
cases becomes really expensive.
What are your experiences?
On 07/11/2014 04:33 PM, Caio Fernando Bertoldi Paes de Andrade wrote:
> Frederik,
>
>> Do you begin with test-driving the use cases, the entities, or the gateways?
>
> I unit-test-drive use cases. I integration-test-drive gateways. :-)
>
>> Is it wrong to test-drive the interface and should I only test implementation?
>
> It's ok to refer to the interactor class directly in your tests.
>
>> The same goes for the entities. [...] How do we test-drive their structure?
>
> I don't write tests for entities. Entities appear in my designs as refactorings extracted from use cases, so they are already covered indirectly by the unit tests. Since I don't have tests coupled to entities, I can refactor them very easily, and I love that.
>
>> I have watched Uncle Bob's clean-coder videos on TDD, so please don't refer to them, as they don't provide answers to my problems.
>
> I'm sure those answers were given by Uncle Bob somewhere, maybe here in the discussion, maybe in the cleancoders videos, maybe in some blog post or some talk he gave in some conference. I'm sure he talked about those issues, but not sure where nor when.
>
> Caio
>
> On 11 Jul 2014, at 09:55, Frederik Krautwald <
fkrau...@gmail.com> wrote:
>
>> I've been for the past couple of weeks struggling with TDD of the Interactor-Entity-Gateway architecture. What I mean is I don't know where to begin. Do you begin with test-driving the use cases, the entities, or the gateways?
>>
>> If I begin with a use case (interactor), I face the problem that the architecture proposes an interface (boundary), which follows the command pattern with no return value, i.e., its execute method takes a request model and a response recipient as arguments, and the response recipient should get called with either its success or failure methods. This leads to mocking, but as the boundary interface has no implementation yet, it is also mocked.
>>
>> Is it wrong to test-drive the interface and should I only test implementation?
>>
>> The same goes for the entities. They are have abstract methods and no implementation on the interactor side. How do we test-drive their structure?
>>
>> I end up writing unit tests for the implementation of entities first, which happens to be outside the interactor side, usually in the repository.
>>
>> I would really appreciate some guidance with test-driving the Interactor-Entity-Gateway architecture. I have watched Uncle Bob's clean-coder videos on TDD, so please don't refer to them, as they don't provide answers to my problems.
>>
>> Many thanks.
>>
>> --
>> The only way to go fast is to go well.
>> ---
>> You received this message because you are subscribed to the Google Groups "Clean Code Discussion" group.
>> To unsubscribe from this group and stop receiving emails from it, send an email to
clean-code-discu...@googlegroups.com.
>> To post to this group, send email to
clean-code...@googlegroups.com.
>> Visit this group at
http://groups.google.com/group/clean-code-discussion.
>
--
Jakob Holderbaum, B.Sc
Systems Engineer
0176 637 297 71
http://jakob.io
h...@jakob.io
#hldrbm