Ecosyste.ms: Awesome

An open API service indexing awesome lists of open source software.

Awesome Lists | Featured Topics | Projects

https://github.com/tng/archunit

A Java architecture test library, to specify and assert architecture rules in plain Java
https://github.com/tng/archunit

Last synced: 1 day ago
JSON representation

A Java architecture test library, to specify and assert architecture rules in plain Java

Awesome Lists containing this project

README

        

[![CI](https://github.com/TNG/ArchUnit/actions/workflows/build.yml/badge.svg)](https://github.com/TNG/ArchUnit/actions/workflows/build.yml?query=branch%3Amain++)
[![Maven Central](https://maven-badges.herokuapp.com/maven-central/com.tngtech.archunit/archunit/badge.svg)](http://search.maven.org/#search%7Cgav%7C1%7Cg%3A%22com.tngtech.archunit%22%20)
[![License](https://img.shields.io/github/license/TNG/ArchUnit.svg)](https://github.com/TNG/ArchUnit/blob/main/LICENSE)

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. 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.3.0'
```

###### Maven

```

com.tngtech.archunit
archunit
1.3.0
test

```

#### Create a test

```java
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
![ArchUnit Fluent API](ArchUnit-API.gif)

## Where to look next

For further information, check out the user guide at [http://archunit.org](http://archunit.org)
or test examples for the current release at
[ArchUnit Examples](https://github.com/TNG/ArchUnit-Examples).

## License

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

It redistributes some third party libraries:

* ASM (http://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](licenses) folder.