Subcutaneous Testing VS End-To-End Testing Through Ports

461 views
Skip to first unread message

Erik Ashepa

unread,
Dec 16, 2013, 4:53:32 PM12/16/13
to growing-object-o...@googlegroups.com
Hi,
I've read the book recently and i must say it was a *GREAT* read!

I've worked on an enterprise system containing about 1000 "Acceptance Tests" which interact with the application from the "ViewModel" (As in MvvM Pattern) collaborating with external processes and message brokers all the way to verifying the operation results in the database.
These tests are very fragile (due to the the actual asynchronous infrastructure involved) and *VERY* slow - about 2-3 hours, in which we rarely restart the services (most tests arrange the state from scratch before acting and verifying, thus not affecting later tests)

i'm starting to work on a new greenfield project in which i'm biased to write the "End-To-End" tests as "Subcutaneous Tests",  as in :
Mocking the API/Persistence and staying within the process boundary.

I am planning to write integration tests for the infrastructure (REST API, ORM/Persistence) and unit tests for driving the actual implementation.

When employing the Hexagonal Architecture (Ports and Adapters), this style will lead me to test the use case (application) layer directly driving the domain layer which is  different from the approach used in the book.

From your experience is this compromise for test execution vs testing scope can work?

Thanks in advance,
Erik.

P.S
Theoretically i could inject the actual infrastructure implementations instead of the mocks to test End-To-End for release purposes or is it too complicated?

Nat Pryce

unread,
Dec 16, 2013, 6:14:11 PM12/16/13
to growing-object-o...@googlegroups.com
It all depends.  But, I prefer to run acceptance tests against the domain model directly -- they are much faster and more reliable than running end to end tests.

The worked example in GOOS grew the app from a small main function that had no structure and could only be tested end-to-end to the point at which the ports-and-adaptors emerged by refactoring, at which point future acceptance tests could be written against the domain model and far fewer end to end tests would be necessary for further development.  In retrospect we were not as explicit about that transition as we should have been.

--Nat



--
 
---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriente...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.



--
http://www.natpryce.com

Erik Ashepa

unread,
Dec 17, 2013, 12:52:30 AM12/17/13
to growing-object-o...@googlegroups.com
Thanks Nat!

When you're saying that you prefer to run acceptance tests against the domain model directly, do your test fixture instantiates and references domain objects directly? or through a use-case/application layer class?

If you're skipping the application layer, aren't you in danger of duplicating the workflow logic in the test fixture?

Thanks in advance,
Erik.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriented-software+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

Erik Ashepa

unread,
Dec 17, 2013, 12:58:15 AM12/17/13
to growing-object-o...@googlegroups.com
BTW,
Are acceptance/end-to-end tests synonyms in your terminology or are different?

Nat Pryce

unread,
Dec 17, 2013, 1:48:35 AM12/17/13
to growing-object-o...@googlegroups.com
I mean that the acceptance tests call into and provide fake implementations of the domain model's ports.

To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriente...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriente...@googlegroups.com.
Message has been deleted

Erik Ashepa

unread,
Dec 17, 2013, 2:22:23 AM12/17/13
to growing-object-o...@googlegroups.com
Ok, i get it now after reading your:

The "Ports" *ARE* the use case "circle", this post definitely filled in the blanks i had after reading the book.. Thanks!

Did you ever tried to re-use the same tests using the actual implementations to achieve system tests?

Erik.

On Tuesday, December 17, 2013 9:07:15 AM UTC+2, Erik Ashepa wrote:
Don't you have a use case "circle" around the domain model as in :

The ports (and their fake implementations) call the domain model directly?
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriented-software+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

--
 
---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriented-software+unsubscribe@googlegroups.com.

Nat Pryce

unread,
Dec 17, 2013, 2:25:44 AM12/17/13
to growing-object-o...@googlegroups.com
"Acceptance" and "end-to-end" are orthogonal.

Acceptance tests may run end-to-end or against the domain model.

End-to-end tests may be used as acceptance tests or be used only by developers for integration or soak testing.

BTW,
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriente...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.
 
---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriente...@googlegroups.com.

Erik Ashepa

unread,
Dec 17, 2013, 2:36:51 AM12/17/13
to growing-object-o...@googlegroups.com
Thanks,
Let me rephrase the question:

Do you try to re-use the same acceptance tests for testing end-to-end *and* testing again the domain model?
BTW,
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriented-software+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

--
 
---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriented-software+unsubscribe@googlegroups.com.

Nat Pryce

unread,
Dec 17, 2013, 3:41:57 AM12/17/13
to growing-object-o...@googlegroups.com
I've not. I've used e2e tests to demonstrate basic capabilities ("the user can buy stuff") and tests against the domain model to demonstrate business rules in more detail ("if the user spends over £50 they get free shipping").

But other people on this list have had more success than I writing test code that can validate the same spec-by-example documents against different rings of the ports & adaptors architecture.

BTW,
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriente...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

--
 
---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriente...@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

--
 

---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriente...@googlegroups.com.

Erik Ashepa

unread,
Dec 17, 2013, 5:07:47 AM12/17/13
to growing-object-o...@googlegroups.com
Thanks once again Nat, I'll continue to spread the word about your great book!

If your planning to publish another revision, i think it would be nice to add more details about e2e vs port to port testing and their trade off.
BTW,
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriented-software+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

--
 
---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriented-software+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/groups/opt_out.

--
 
---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriented-software+unsubscribe@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages