-
-
Notifications
You must be signed in to change notification settings - Fork 528
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Testable architecture #86
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I commented on tiny details of this article, which I think is a good article. It introduces the area.
content/testable-architecture.md
Outdated
Automated tests and executable specifications can only work with software that has a testable architecture. | ||
A testable architecture enables fast and reliable tests that are easy to write, execute and maintain. | ||
Fast tests enable the developers to run them and obtain fast feedback on what they are building, without loosing focus or flow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
loosing => losing
content/testable-architecture.md
Outdated
We want our tests to use some kind of in-memory stub implementation, instead of an actual database. | ||
From the perspective of the domain logic, the behavior looks exactly the same. | ||
To make sure that the stub works in the same way as the real thing, we need to have confidence, which we can obtain using ‘contract tests’. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is the ornamentation around contract tests exactly what you want, here?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure what you mean here. Do you mean the ' ' around 'contract tests'? Copied that from the https://sdjournal.org/bdd-like-jazz/ blogpost.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean the single quotes, yes.
Is "contract tests" not official naming, then perhaps single quotes are fine, but if we wish to make it stand out, then bold type could perhaps be helpful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
See, I'm all weasel words and equivocating. Sorry about that.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No problem. Thank you for proof reading all the time! It's hard to see the details when you've written and read the same doc several times. I really, really appreciate you taking the time to review; it makes the end result that much better!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not sure if 'contract tests' is the 'official' name (see, doing it again with the ' '). There seems to be a lot of misunderstanding about different types of tests all the time. I might just rewrite a little bit and avoid the term 'contract tests' (unless someone can provide a link/definition).
content/testable-architecture.md
Outdated
|
||
This architectural patterns is called the **ports and adapters pattern** (or [hexagonal architecture](http://alistair.cockburn.us/Hexagonal+architecture)). | ||
This pattern enables you to hook your scenarios and unit tests at a lower level, while he 'contract tests' give you the confidence to do that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
he => the
@olleolleolle I've added a link to some more information about contract testing, which I hope helps a little for people unfamiliar with the term. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for introducing this area.
content/testable-architecture.md
Outdated
Automated tests and executable specifications can only work with software that has a testable architecture. | ||
A testable architecture enables fast and reliable tests that are easy to write, execute and maintain. | ||
Fast tests enable the developers to run them and obtain fast feedback on what they are building, without losing focus or flow. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
... enable the developers to run them and obtain ...
could use an additional word
... enable the developers to run them continuously and obtain ...
... enable the developers to run them often and obtain ...
... enable the developers to run them frequent and obtain ...
I'm not sure if the extra word should be 'continuously', 'often' or 'frequent'
content/testable-architecture.md
Outdated
When designing for testability, make sure that your products and services are composed of loosely-coupled, | ||
well-encapsulated components or modules; following the principles of | ||
[SOLID design](https://en.wikipedia.org/wiki/SOLID_(object-oriented_design)). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would end this paragraph
... services are composed of loosely-coupled, well-encapsulated components or modules.
I wouldn't include the SOLID principles here. They could be added as a resource at the end instead.
content/testable-architecture.md
Outdated
makes it possible to test at different levels, with maximum confidence and minimum cost. | ||
|
||
* Ensure that you can run your tests underneath your UI. Do not depend solely on UI tests. They are slow, expensive, and hard to fix. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would replace 'underneath' with 'below'.
I would also not use the abbrevation UI. I would introduce it as
... below your user interface, UI.
I would add brittle to the list of properties for a UI test.
They are slow, brittle, expensive, and hard to fix.
content/testable-architecture.md
Outdated
* Running tests against a database makes tests slow. And to make the tests behave consistently each time we run them, | ||
we need to make sure the database is in the expected state for each test, so the tests don't interfere with one another. | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would turn around this sentence:
"And to make the tests behave consistently each time we run them, we need to make sure the database is in the expected state for each test, so the tests don't interfere with one another."
Something like this:
We need to make sure the database is in the expected state for each test in order to make the tests behave consistently. This will ensure that the tests don't interfere with each other and can be executed in any order.
content/testable-architecture.md
Outdated
we need to make sure the database is in the expected state for each test, so the tests don't interfere with one another. | ||
|
||
We want our tests to use some kind of in-memory stub implementation, instead of an actual database. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would rephrase "We want our tests to use some kind of in-memory stub implementation, instead of an actual database." as
"We want most of our tests to use some kind of in-memory stub implementation, instead of an actual database."
Making it a bit softer.
content/testable-architecture.md
Outdated
|
||
We want our tests to use some kind of in-memory stub implementation, instead of an actual database. | ||
From the perspective of the domain logic, the behavior looks exactly the same. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would replace 'looks' with 'is'
content/testable-architecture.md
Outdated
|
||
We can think of our database and our stub as two things that can be plugged into the same socket, or **port**. | ||
The application containing the business logic doesn't need to know it's talking to a stub rather than the actual database; it's simply talking to this port |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would add 'if' in "doesn't need to know it's talking"
so it becomes
"doesn't need to know if it is talking"
I would also consider replacing 'rather than' with 'or'
content/testable-architecture.md
Outdated
|
||
The business logic is at the core of the application, completely decoupled from external devices and services. It doesn’t know anything about databases, message queues, | ||
and web services because we’ve isolated them through these ports. Often, these ports are connected to adapters that interact with the real implementation. There will be an adapter for the database, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would change the 'and' in the enumeration of techniques to 'or' as in
"It doesn’t know anything about databases, message queues, and web services because ..."
would become
"It doesn’t know anything about databases, message queues, or web services because ..."
I would also use the complete words 'we have' instead of 'we’ve'
content/testable-architecture.md
Outdated
and web services because we’ve isolated them through these ports. Often, these ports are connected to adapters that interact with the real implementation. There will be an adapter for the database, | ||
an adapter for the queue, and an adapter for the web service. There is also a port that defines how we can interact with our system, such as | ||
a web server which plugs into this port and displays a UI in a browser. All the IO tends to happen outside of these ports. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure I understand what you mean in this sentense:
"There is also a port that defines how we can interact with our system, such as a web server which plugs into this port and displays a UI in a browser. All the IO tends to happen outside of these ports."
I think it is the beginning that confuses me, 'There is also a port'
content/testable-architecture.md
Outdated
|
||
This architectural patterns is called the **ports and adapters pattern** (or [hexagonal architecture](http://alistair.cockburn.us/Hexagonal+architecture)). | ||
This pattern enables you to hook your scenarios and unit tests at a lower level, while the **contract tests** give you the confidence to do that. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would remove the word 'the' before ports and adapter. Can't motivate more than I think it reads better.
I would replace 'This pattern' with 'It' and thus avoid the word This twice in two sentences next to each other.
I would use the word 'connect' instead of 'hook'
content/testable-architecture.md
Outdated
Diagnosing where the problem is in a full-stack, end-to-end test is really hard, because it can be anywhere. | ||
These tests are brittle because one change can break all your tests. They are also slow, | ||
as there is IO involved when going through a a browser, web service or database. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would consider replacing "can break all your tests" with "can break all of them"
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this can be merged.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Excellent job @mlvandijk! You nailed it!
To make sure that the stub works in the same way as the real thing, we need to have confidence, which we can obtain using [contract tests](https://martinfowler.com/bliki/IntegrationContractTest.html). | ||
|
||
We can think of our database and our stub as two things that can be plugged into the same socket, or **port**. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think the word "socket" can easily be misunderstood as "TCP socket", so maybe clarify that it is a "socket", not a socket :-)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @aslakhellesoy ! Yeah, the "socket" here is used as a metaphor; I'll just remove it to avoid confusion.
First version of Testable Architecture, of what I think is intended here, based on several blogs and podcasts.
Sources are listed under "More information:" but could be moved to blog-posts (and recommended media?).
Please review to see if I got the right meaning and didn't over simplify in my summary.