Romain Tribes
Romain Tribes

Reputation: 1818

How to test the behaviour with DCI pattern?

I'm writing a simple webgame to experiment the DCI pattern and I was wondering how to test the context properly.

https://gist.github.com/1718889

I have a context CharacterAttacksAnotherCharacter which take two characters and extend them with two roles (Attacker and Target). Then the context is executed.

But, how can I test the behaviour of this execution instead of the implementation?

Thanks!

Upvotes: 3

Views: 381

Answers (1)

Rune FS
Rune FS

Reputation: 21742

In general testing an interaction in a DCI context should be fairly easy. One of the goals of the context is to be self contained, so binding roles to objects that suits the testing should be straight forward. If it's not that's probably a sign that it's not really DCI. I have a hard time finding any role methods in your code. That might be due to my lack of ruby skills. In general the interaction should be a complete algorithm and that is what you would want to test when creating unit test for a context. However a goal of DCI is to create a verifiable code unit so if that goal is reach there'd be other parts of the code where the testing efforts yield a higher value compared to using reviews to verify the implementation of the context and it's interactions

Upvotes: 1

Related Questions