MCPcopy Index your code
hub / github.com/TNG/ArchUnit-Examples

github.com/TNG/ArchUnit-Examples @main

Chat with this repo
repository ↗ · DeepWiki ↗ · + Follow
1,273 symbols 2,254 edges 563 files 20 documented · 2%
What it actually does AI analysis from the code graph — generated when you open this
loading…
README

ArchUnit Examples

This module presents some examples on how to use the latest release of ArchUnit.

The different subprojects demonstrate the type of test support: * example-junit4 shows how to use the JUnit 4 test support including the ArchUnitRunner * example-junit5 shows how to use the JUnit 5 test support where test classes are simply being picked up by being annotated with @AnalyzeClasses * example-plain shows how to use ArchUnit independently of any specific test framework, even though as a runtime environment these tests use JUnit 4 as well

All example rules you find within src/test refer to classes from src/main. These tests are all designed to fail, to demonstrate how production code could violate typical architectural constraints (like layer dependencies).

You can run them

  • with Gradle (using the provided build.gradle scripts): sh ./gradlew test
  • with Maven (using the provided pom.xml files in the same directories): sh ./mvnw test
  • or directly from your IDE.

Regarding issues

If you have found any issues with the examples or have any question, please direct them to the main repository instead. This repository is an autogenerated version of the latest released version of https://github.com/TNG/ArchUnit/tree/main/archunit-example (with some simplified project setup for illustration)

Extension points exported contracts — how you extend this code

AdministrationPort (Interface)
(no doc) [6 implementers]
example-junit5/src/main/java/com/tngtech/archunit/example/onionarchitecture/application/AdministrationPort.java
AdministrationPort (Interface)
(no doc) [6 implementers]
example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/application/AdministrationPort.java
AdministrationPort (Interface)
(no doc) [6 implementers]
example-junit4/src/main/java/com/tngtech/archunit/example/onionarchitecture/application/AdministrationPort.java
ShoppingCartRepository (Interface)
(no doc) [7 implementers]
example-junit5/src/main/java/com/tngtech/archunit/example/onionarchitecture/adapter/persistence/ShoppingCartRepository.java
ShoppingCartRepository (Interface)
(no doc) [7 implementers]
example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/adapter/persistence/ShoppingCartRepository.java
ShoppingCartRepository (Interface)
(no doc) [7 implementers]
example-junit4/src/main/java/com/tngtech/archunit/example/onionarchitecture/adapter/persistence/ShoppingCartRepository.java
ProductRepository (Interface)
(no doc) [7 implementers]
example-junit5/src/main/java/com/tngtech/archunit/example/onionarchitecture/adapter/persistence/ProductRepository.java
ProductRepository (Interface)
(no doc) [7 implementers]
example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/adapter/persistence/ProductRepository.java

Core symbols most depended-on inside this repo

read
called by 10
example-junit4/src/main/java/com/tngtech/archunit/example/onionarchitecture_by_annotations/onion/product/ProductRepository.java
getInstanceOf
called by 6
example-junit4/src/main/java/com/tngtech/archunit/example/onionarchitecture_by_annotations/onion/AdministrationPort.java
save
called by 6
example-junit4/src/main/java/com/tngtech/archunit/example/onionarchitecture_by_annotations/onion/shopping/ShoppingCartRepository.java
isEmpty
called by 4
example-junit5/src/main/java/com/tngtech/archunit/example/cycles/simplescenario/report/Report.java
isEmpty
called by 4
example-plain/src/main/java/com/tngtech/archunit/example/cycles/simplescenario/report/Report.java
isEmpty
called by 4
example-junit4/src/main/java/com/tngtech/archunit/example/cycles/simplescenario/report/Report.java
doCoreStuff
called by 3
example-junit5/src/main/java/com/tngtech/archunit/example/layers/core/VeryCentralCore.java
add
called by 3
example-plain/src/main/java/com/tngtech/archunit/example/onionarchitecture/domain/model/ShoppingCart.java

Shape

Method 765
Class 442
Interface 57
Enum 9

Languages

Java100%

Modules by API surface

example-plain/src/test/java/com/tngtech/archunit/exampletest/ModulesTest.java16 symbols
example-plain/src/test/java/com/tngtech/archunit/exampletest/CyclicDependencyRulesTest.java13 symbols
example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/SessionBeanRulesTest.java12 symbols
example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/SessionBeanRulesTest.java12 symbols
example-plain/src/test/java/com/tngtech/archunit/exampletest/SessionBeanRulesTest.java9 symbols
example-plain/src/test/java/com/tngtech/archunit/exampletest/LayerDependencyRulesTest.java9 symbols
example-plain/src/test/java/com/tngtech/archunit/exampletest/CodingRulesTest.java9 symbols
example-junit5/src/test/java/com/tngtech/archunit/exampletest/junit5/ModulesTest.java9 symbols
example-junit4/src/test/java/com/tngtech/archunit/exampletest/junit4/ModulesTest.java9 symbols
example-plain/src/test/java/com/tngtech/archunit/exampletest/extension/NewConfigurationEvent.java7 symbols
example-plain/src/test/java/com/tngtech/archunit/exampletest/extension/ExampleExtension.java7 symbols
example-plain/src/test/java/com/tngtech/archunit/exampletest/ControllerRulesTest.java7 symbols

For agents

$ claude mcp add ArchUnit-Examples \
  -- python -m otcore.mcp_server <graph>

⬇ download graph artifact