- Understand the advantages of using a library like
ArchUnit
- Clarify how we can use it on a daily basis
In group, discuss:
- What are your current
architecture rules
inside your team - How you ensure that your code is always matching those rules
Examples :
- All our events must reside in the events package
- Our repository layer can only be accessed through our application layer
- …
You can use the slides available here for this part
To simplify the usage of the library during this kata some preparation work has already been made:
- Dependencies are already there:
TngTech.ArchUnitNet
andTngTech.ArchUnitNet.xUnit
ArchUnitExtensions
contains some extensions that could help you tocheck
rules- Test classes have been provided but implementations are missing
- You have to fill the gap to implement the rule expressed in plain text english correctly
- Do it for each rule using the
EmptyRule
- Do it for each rule using the
- If you want, you can
fix
the production code based on theArchRule
discoveries - Optional
- You have to fill the gap to implement the rule expressed in plain text english correctly
public class Guidelines
{
[Fact]
public void ClassShouldNotDependOnAnother() =>
EmptyRule("Class SomeExample should not depend on Other")
.Check();
}
- We use the
ArchUnit
dsl to write it- Let the public
api
guide you - Think
dot-driven development
- Let the public
[Fact]
public void ClassShouldNotDependOnAnother() =>
Classes().That()
.Are(typeof(SomeExample))
.Should()
.NotDependOnAny(typeof(Other))
.Check();
Recommended order (do at least 1 per category / test class
):
LayeredArchitecture
NamingConvention
Guidelines
LinguisticAntiPatterns
MethodsReturnTypes
Annotations
Which other rules
could be added?
Solution is available in the solution
folder
- What can we do with it ?
- Which rules could be useful ?