Skip to content

Commit 11fb56e

Browse files
authored
Update maven-test-reuse.asciidoc
1 parent d8cdcbe commit 11fb56e

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

documentation/build/maven-test-reuse.asciidoc

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,10 @@ You can have your test-infrastructure depend on code from `src/main/java` in the
5959
Cons:
6060

6161
* **Broken Design**: +
62-
The test jar contains all your test-code (compiled from `src/test/java` including `src/test/resources`) and never are a well defined module API (in the example also `SomeClassTest` sneaks in).
62+
The test jar contains all your test-code (compiled from `src/test/java` including `src/test/resources`) and never has a well defined module API (in the example also `SomeClassTest` sneaks in).
6363
Therefore you mess your design of test-infrastructure since also JUnit tests from other modles sneak onto the classpath of other modules and get visible in code-completion, etc.
64+
However, your tests of a module should be considered as an "implementation secret".
65+
The idea of modules is encapsulation (SoC) and if you make all your test-code visible to all other modules you easily violate this principle.
6466
* **Flawed Dependencies**: +
6567
The dependency type `test-jar` has been added to maven but due to its complexity it is not consistent.
6668
You might expect that the test-depdendencies of your `test-jar` dependency are transitive but this is not the case (maven never treats `test` scoped dependencies transitive).
@@ -133,7 +135,7 @@ For each set of reusable test-infrastructure you need to create an additional ma
133135
Sometimes you end up with a problem since obviously maven does not support cyclic dependencies and has to be able to build each module independently.
134136
In the example above you might have the problem that `CoolTestExtension` requires `SomeClass`.
135137
Now if `SomeClassTest` dependends both on `SomeClass` and on `CoolTestExtension`, you end up in a problem that can easily be solved with `test-jars` approach.
136-
To solve it, you could move `SomeClassTest` to `my-module-test/src/test/java`.
138+
To solve it without `test-jars`, you could move `SomeClassTest` to `my-module-test/src/test/java`.
137139
In general it is better to design test-infrastructure to avoid such problems.
138140

139141
== Conclusion

0 commit comments

Comments
 (0)