1
1
<!DOCTYPE html>
2
- < html lang ="en ">
2
+ < html lang ="">
3
3
< head >
4
4
< meta charset ="UTF-8 ">
5
5
< meta http-equiv ="X-UA-Compatible " content ="IE=edge ">
450
450
< div id ="header ">
451
451
< h1 > ArchUnit User Guide</ h1 >
452
452
< div class ="details ">
453
- < span id ="revnumber "> version 1.3 .0</ span >
453
+ < span id ="revnumber "> version 1.4 .0</ span >
454
454
</ div >
455
455
< div id ="toc " class ="toc2 ">
456
456
< div id ="toctitle "> Table of Contents</ div >
@@ -619,7 +619,7 @@ <h3 id="_junit_4"><a class="anchor" href="#_junit_4"></a>2.1. JUnit 4</h3>
619
619
< pre class ="highlightjs highlight nowrap "> < code class ="language-xml hljs " data-lang ="xml "> <dependency>
620
620
<groupId>com.tngtech.archunit</groupId>
621
621
<artifactId>archunit-junit4</artifactId>
622
- <version>1.3 .0</version>
622
+ <version>1.4 .0</version>
623
623
<scope>test</scope>
624
624
</dependency></ code > </ pre >
625
625
</ div >
@@ -628,7 +628,7 @@ <h3 id="_junit_4"><a class="anchor" href="#_junit_4"></a>2.1. JUnit 4</h3>
628
628
< div class ="title "> build.gradle</ div >
629
629
< div class ="content ">
630
630
< pre class ="highlightjs highlight nowrap "> < code class ="language-none hljs "> dependencies {
631
- testImplementation 'com.tngtech.archunit:archunit-junit4:1.3 .0'
631
+ testImplementation 'com.tngtech.archunit:archunit-junit4:1.4 .0'
632
632
}</ code > </ pre >
633
633
</ div >
634
634
</ div >
@@ -649,7 +649,7 @@ <h3 id="_junit_5"><a class="anchor" href="#_junit_5"></a>2.2. JUnit 5</h3>
649
649
< pre class ="highlightjs highlight nowrap "> < code class ="language-xml hljs " data-lang ="xml "> <dependency>
650
650
<groupId>com.tngtech.archunit</groupId>
651
651
<artifactId>archunit-junit5</artifactId>
652
- <version>1.3 .0</version>
652
+ <version>1.4 .0</version>
653
653
<scope>test</scope>
654
654
</dependency></ code > </ pre >
655
655
</ div >
@@ -658,7 +658,7 @@ <h3 id="_junit_5"><a class="anchor" href="#_junit_5"></a>2.2. JUnit 5</h3>
658
658
< div class ="title "> build.gradle</ div >
659
659
< div class ="content ">
660
660
< pre class ="highlightjs highlight nowrap "> < code class ="language-none hljs "> dependencies {
661
- testImplementation 'com.tngtech.archunit:archunit-junit5:1.3 .0'
661
+ testImplementation 'com.tngtech.archunit:archunit-junit5:1.4 .0'
662
662
}</ code > </ pre >
663
663
</ div >
664
664
</ div >
@@ -675,7 +675,7 @@ <h3 id="_other_test_frameworks"><a class="anchor" href="#_other_test_frameworks"
675
675
< pre class ="highlightjs highlight nowrap "> < code class ="language-xml hljs " data-lang ="xml "> <dependency>
676
676
<groupId>com.tngtech.archunit</groupId>
677
677
<artifactId>archunit</artifactId>
678
- <version>1.3 .0</version>
678
+ <version>1.4 .0</version>
679
679
<scope>test</scope>
680
680
</dependency></ code > </ pre >
681
681
</ div >
@@ -684,7 +684,7 @@ <h3 id="_other_test_frameworks"><a class="anchor" href="#_other_test_frameworks"
684
684
< div class ="title "> build.gradle</ div >
685
685
< div class ="content ">
686
686
< pre class ="highlightjs highlight nowrap "> < code class ="language-none hljs "> dependencies {
687
- testImplementation 'com.tngtech.archunit:archunit:1.3 .0'
687
+ testImplementation 'com.tngtech.archunit:archunit:1.4 .0'
688
688
}</ code > </ pre >
689
689
</ div >
690
690
</ div >
@@ -2658,7 +2658,7 @@ <h4 id="_writing_tests"><a class="anchor" href="#_writing_tests"></a>9.1.1. Writ
2658
2658
< h4 id ="_controlling_the_import "> < a class ="anchor " href ="#_controlling_the_import "> </ a > 9.1.2. Controlling the Import</ h4 >
2659
2659
< div class ="paragraph ">
2660
2660
< p > Which classes will be imported can be controlled in a declarative way through < code > @AnalyzeClasses</ code > .
2661
- If no packages or locations are provided, the whole classpath will be imported.
2661
+ If no packages or locations are provided, the package of the annotated test class will be imported.
2662
2662
You can specify packages to import as strings:</ p >
2663
2663
</ div >
2664
2664
< div class ="listingblock ">
@@ -2705,6 +2705,35 @@ <h4 id="_controlling_the_import"><a class="anchor" href="#_controlling_the_impor
2705
2705
< p > As explained in < a href ="#_the_core_api "> The Core API</ a > , you can write your own custom implementation of < code > ImportOption</ code >
2706
2706
and then supply the type to < code > @AnalyzeClasses</ code > .</ p >
2707
2707
</ div >
2708
+ < div class ="paragraph ">
2709
+ < p > To import the whole classpath, instead of just the package of the test class, use the option</ p >
2710
+ </ div >
2711
+ < div class ="listingblock ">
2712
+ < div class ="content ">
2713
+ < pre class ="highlightjs highlight nowrap "> < code class ="language-java hljs " data-lang ="java "> @AnalyzeClasses(wholeClasspath = true)</ code > </ pre >
2714
+ </ div >
2715
+ </ div >
2716
+ < div class ="paragraph ">
2717
+ < p > Note that < code > @AnalyzeClasses</ code > can also be used as a meta-annotation to avoid repeating the same configuration:</ p >
2718
+ </ div >
2719
+ < div class ="listingblock ">
2720
+ < div class ="content ">
2721
+ < pre class ="highlightjs highlight nowrap "> < code class ="language-java hljs " data-lang ="java "> @Retention(RetentionPolicy.RUNTIME)
2722
+ @AnalyzeClasses(packagesOf = MyApplicationRoot.class, importOptions = DoNotIncludeTests.class)
2723
+ public @interface AnalyzeMainClasses {}</ code > </ pre >
2724
+ </ div >
2725
+ </ div >
2726
+ < div class ="paragraph ">
2727
+ < p > This annotation can then be used on test classes without repeating the specific configuration of < code > @AnalyzeClasses</ code > :</ p >
2728
+ </ div >
2729
+ < div class ="listingblock ">
2730
+ < div class ="content ">
2731
+ < pre class ="highlightjs highlight nowrap "> < code class ="language-java hljs " data-lang ="java "> @AnalyzeMainClasses
2732
+ public class ArchitectureTest {
2733
+ // ...
2734
+ }</ code > </ pre >
2735
+ </ div >
2736
+ </ div >
2708
2737
</ div >
2709
2738
< div class ="sect3 ">
2710
2739
< h4 id ="_controlling_the_cache "> < a class ="anchor " href ="#_controlling_the_cache "> </ a > 9.1.3. Controlling the Cache</ h4 >
0 commit comments