百科.dev
全部条目AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
A

ArchUnit

> 编程语言
开源

一个 Java 架构测试库,用于使用纯 Java 来指定和验证架构规则

3.8K stars0 点赞0 次浏览
访问官网GitHub

工具介绍

一个 Java 架构测试库,用于使用纯 Java 来指定和验证架构规则

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. It does so by analyzing given Java bytecode, importing all classes into a Java code structure. ArchUnit's main focus is to automatically test architecture and coding rules, using any plain Java unit testing framework.

An Example

Add the Maven Central dependency to your project

Gradle
testImplementation 'com.tngtech.archunit:archunit:1.5.0'
Maven
<dependency>
    <groupId>com.tngtech.archunit</groupId>
    <artifactId>archunit</artifactId>
    <version>1.5.0</version>
    <scope>test</scope>
</dependency>

Create a test

import com.tngtech.archunit.core.domain.JavaClasses;
import com.tngtech.archunit.core.importer.ClassFileImporter;
import com.tngtech.archunit.lang.ArchRule;

import static com.tngtech.archunit.lang.syntax.ArchRuleDefinition.classes;

public class MyArchitectureTest {
    @Test
    public void some_architecture_rule() {
        JavaClasses importedClasses = new ClassFileImporter().importPackages("com.myapp");
    
        ArchRule rule = classes()... // see next section
    
        rule.check(importedClasses);
    }
}

Let the API guide you

Where to look next

For further information, check out the user guide at https://archunit.org or test examples for the current release at ArchUnit Examples.

License

ArchUnit is published under the Apache License 2.0, see https://www.apache.org/licenses/LICENSE-2.0 for details.

It redistributes some third party libraries:

  • ASM (https://asm.ow2.org), under BSD Licence
  • Google Guava (https://github.com/google/guava), under Apache License 2.0

All licenses for ArchUnit and redistributed libraries can be found within the licenses folder.

Issues· 172 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

Java

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类编程语言
定价开源

> 相关工具

T
TypeScript
JavaScript 的超集,为前端与全栈提供静态类型
P
Python
通用编程语言,广泛用于 Web、数据与 AI
G
Go
Google 推出的简洁高效系统语言