-
Notifications
You must be signed in to change notification settings - Fork 55
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
initial draft for unit tests for software architecture using ArchUnit #569
base: master
Are you sure you want to change the base?
initial draft for unit tests for software architecture using ArchUnit #569
Conversation
|
||
ArchUnit is a free, simple and extensible library for checking the architecture of your Java code using any plain Java unit test framework. | ||
|
||
ArchUnit has different layers: the Core layer, the Lang layer, and the Library layer. |
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.
As a user of ArchUnit, this is not the most important fact about ArchUnit. I don't really care about the "layering" of ArchUnit itself. I care about learning which use cases I can use it for and how to use it. Can you rewrite the "What is ArchUnit" section to start with a complete example and then explaining it? Potentially after this, you can explain about the layering.
.resideInAPackage("..service..") | ||
.should() | ||
.onlyBeAccessed() | ||
.byAnyPackage("..controller..", "..service.."); |
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.
Please combine all three code examples in this section to a single one. Start the section with a sentence about what ArchUnit is, then show the code example, then explain the code example. That's the best way to introduce ArchUnit to the readers.
|
||
## What to check | ||
|
||
What should we check in architectural tests in the first place? The typical checks we can do with ArchUnit are class dependencies and package dependency checks to enforce dependency rules in a class or between classes in different packages. Package dependency check is commonly used in Spring Modulith applications to check that classes do not depend on a class in another bounded context. |
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.
You're assuming the reader knows what Moduliths is ... please don't do that.
In general, this section is rather weak. As a reader, I don't really learn from this section what I can do with ArchUnit. I would like to see a couple subsections in this section, each explaining a certain use case in a sentence or two.
|
||
## Getting started with ArchUnit | ||
|
||
Let us create a Spring Boot application. Although the example in this article is a bit contrived, it can help us understand how to use ArchUnit in a typical web application with different layers. |
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.
The part of this article about creating a new Spring Boot application takes up over 50% of the article. This article is about ArchUnit and not Spring Boot.
I think we can remove the whole start.spring.io stuff and just show some very simple example classes that have all the features you need for the use cases you're showing. Instead of the Spring Boot stuff, feel free to add more than the two example ArchUnit use cases.
I also suggest to put the code examples directly into the use case sections. I.e. In the section "Test to check repositories are only accessed by services", start with showing two very simple service and repository classes, and then show the ArchUnit test.
Please read through the writing guide before submitting a pull request and go through this checklist (at least for your first article).
Feel free to raise the pull request even if the checklist hasn't been worked through, yet, to take advantage of the online preview that is generated for each pull request (see "deploy/netlify" under "Show all checks" in your pull request). But please only flag it to be reviewed by your editor after going through the checklist.
Review
Content
Text
code
Structure
Code Examples