ArchUnit

A Java architecture test library, to specify and assert architecture rules in plain Java - Module 'archunit-junit'

License

License

Categories

Categories

JUnit Unit Testing
GroupId

GroupId

com.tngtech.archunit
ArtifactId

ArtifactId

archunit-junit
Last Version

Last Version

0.8.3
Release Date

Release Date

Type

Type

jar
Description

Description

ArchUnit
A Java architecture test library, to specify and assert architecture rules in plain Java - Module 'archunit-junit'
Project URL

Project URL

https://github.com/TNG/ArchUnit
Project Organization

Project Organization

TNG Technology Consulting GmbH
Source Code Management

Source Code Management

https://github.com/TNG/ArchUnit

Download archunit-junit

How to add to project

<!-- https://jarcasting.com/artifacts/com.tngtech.archunit/archunit-junit/ -->
<dependency>
    <groupId>com.tngtech.archunit</groupId>
    <artifactId>archunit-junit</artifactId>
    <version>0.8.3</version>
</dependency>
// https://jarcasting.com/artifacts/com.tngtech.archunit/archunit-junit/
implementation 'com.tngtech.archunit:archunit-junit:0.8.3'
// https://jarcasting.com/artifacts/com.tngtech.archunit/archunit-junit/
implementation ("com.tngtech.archunit:archunit-junit:0.8.3")
'com.tngtech.archunit:archunit-junit:jar:0.8.3'
<dependency org="com.tngtech.archunit" name="archunit-junit" rev="0.8.3">
  <artifact name="archunit-junit" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.tngtech.archunit', module='archunit-junit', version='0.8.3')
)
libraryDependencies += "com.tngtech.archunit" % "archunit-junit" % "0.8.3"
[com.tngtech.archunit/archunit-junit "0.8.3"]

Dependencies

compile (2)

Group / Artifact Type Version
com.tngtech.archunit : archunit jar 0.8.3
junit : junit jar 4.12

Project Modules

There are no modules declared in this project.

Build Status Maven Central 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:0.14.1'
Maven
<dependency>
    <groupId>com.tngtech.archunit</groupId>
    <artifactId>archunit</artifactId>
    <version>0.14.1</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

ArchUnit Fluent API

Where to look next

For further information, check out the user guide at http://archunit.org or test examples for the current release at 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:

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

com.tngtech.archunit

TNG Technology Consulting GmbH

TNG Technology Consulting GmbH is a value-based consulting partnership focused on high end information technology.

Versions

Version
0.8.3
0.8.2
0.8.1
0.8.0
0.5.0
0.4.0