Questions tagged [archunit]
ArchUnit is a free, simple and extensible library for checking the architecture of your Java code. That is, ArchUnit can check dependencies between packages and classes, layers and slices, check for cyclic dependencies and more.
archunit
140
questions
0
votes
1
answer
17
views
Custom gradle Plugin to Run on Client Projects code
In our organization, we have a repository where we export a variety of plugins related to checkstyle, PMD, component testing, and Liquibase, among other things. I created a simple plugin with a task ...
0
votes
1
answer
40
views
Check if a field is initialized with ArchUnit
I have a class that looks like this:
public class A {
private B b1 = new B();
private C c = new C();
private B b2;
}
I want to write an ArchUnit test that finds all the fields in class A ...
0
votes
1
answer
21
views
ArchRule fails on proper test
I have test
@ArchTest
public static final ArchRule daoShouldBeUsedOnlyByHelper = theClass(SegmentDAO.class).should()
.onlyBeAccessed()
.byClassesThat(simpleName(SegmentHelper.class....
0
votes
1
answer
61
views
Checking parameters of all method calls
I work on a Java app which uses a ResourceBundle with a static helper class.
Simplified it works like this:
class Bundle()
{
static String get(key)
{
resourceBundle.get(key)
}
}
uiClass()
{...
0
votes
1
answer
82
views
What belongs in the applicationService package to properly test the onion architecture with ArchUnit?
I am currently in the process of implementing a simple hexagonal architecture. I have followed the DDD principle and placed the DomainModels alongside the DomainServices in a domain-package. In ...
0
votes
1
answer
109
views
Test classes are not fed into ArchUnit test case
I fail to implement an ArchUnit test that is meant to prevent test cases getting written that are named with the work "failed" as part of their method name.
For that I use the ImportOption....
0
votes
1
answer
68
views
Using archunit to enforce all sub-packages only reference themselves of a "common" package
If i have a package structure like:
org.myapp
common
feature1
feature2
...
I would like to write an archunit test that checks if all classes inside the feature packages only reference other classes ...
0
votes
0
answers
25
views
archunit : validating that we never forget root Throwable when rethrowing an exception
Using Archunit, I would like to enforce that whenever we catch an exception and rethrow one, the original Throwable is always included in the constructor of the new exception.
the pseudo algorithm ...
0
votes
1
answer
65
views
ArchUnit: Test a class if it contains an annotated method
I want to write an archunit rule in my J2EE project to test when a class is annotated with @Startup, then it must contain a method that is annotated with @PostConstruct.
I tried this
@ArchTest
...
-1
votes
1
answer
48
views
How do I exclude basic Java functionality from layered architecture tests in ArchUnit?
I have written up the following test for my clean architecture. I still have a lot of violations like java.util functionality. Can I somehow exclude them from the LayeredArchitecture ArchUnit concept?
...
0
votes
1
answer
46
views
ResidesOutsideOfPackages but for classes in arch unit tests
val rule: ArchRule =
noClasses().that().resideInAPackage("$Base.app..")
.should().dependOnClassesThat().resideOutsideOfPackages(allowablePackages)
rule.check(...
0
votes
1
answer
133
views
How to exclude specific classes with ArchUnit tests?
I currently have a simple ArchUnit test that checks that all classes that reside in a package should only be accessed within that class.
However, I want to exclude one specific class from that rule ...
1
vote
0
answers
51
views
C# Arch Unit - Avoid calling System.String.Substring()
I'm trying to understand how to avoid calling a method like "System.String.Substring()" with ArchUnit framework by TNG.
First I have a simple library Lib with static method:
namespace Lib
{
...
0
votes
1
answer
74
views
ArchUnitTest not running as expected
Could anyone say why am I getting these errors, given the configurations below?
Message:
ArchUnitNET.xUnit.FailedArchRuleException : "Classes that are Classes that are Classes that implement '...
0
votes
1
answer
183
views
ArchUnit: how to check for extension of an interface?
I have a package for which I want to check that all classes (these are entities that can get shipped over the net) do indeed implement the interface "java.io.Serializable".
So I defined ...