Arc Unit
What
Is ArchUnit?
ArchUnit is
a testing library used for defining and enforcing dependencies between classes,
packages, and/or layers. It can also be used for establishing conventions, like
class names, encapsulation or immutability. It supports JUnit 4 and JUnit 5
libraries; therefore, it is very easy to integrate these tests in any pipeline.
Simply
put, ArchUnit is a test library that allows us to verify that
an application adheres to a given set of architectural rules.
ArchUnit integrates nicely with
the JUnit test framework, and so, they
are typically used together.
<dependency>
<groupId>com.tngtech.archunit</groupId>
<artifactId>archunit-junit4</artifactId>
<version>0.14.1</version> <scope>test</scope>
</dependency>
The first
step is to create a set of Java classes that will be checked for rules
violations. We do
this by instantiating the ClassFileImporter class and then
using one of its importXXX() methods:
JavaClasses jc = new ClassFileImporter()
.importPackages("com.baeldung.archunit.smurfs");
Or by
aanotation?
@AnalyzeClasses(
packages =
"com.fmr.ap165106.price_acquisition_service",
importOptions =
ImportOption.Predefined.DoNotIncludeTests.class)
Hexagonal
architecture test:
Comments
Post a Comment