ArchUnit is run regardless of selected tests scope with JUnit5 in IntelliJ IDEA #546
Closed
Description
Some context to help understand
I have a Kotlin project with the following package structure:
com.example.project
|- domain
|- driving
`- driven
And some ArchUnit tests that ensure that the hexagonal architecture constraints are met in com.example.project.HexagonalArchitectureTest.kt
.
I'm using:
- Kotlin 1.4.31
- ArchUnit 0.17.0
- JUnit 5 5.7.1
- IntelliJ IDEA Ultimate 2020.3
The problem I'm facing
Whenever I run a subset of my tests in IntelliJ IDEA, say by hitting Ctrl+Shift+F10 on the domain
package, the test console shows a bunch of ArchUnit-related logs before actually running the tests I've selected, starting with:
13:51:05.266 [main] INFO com.tngtech.archunit.core.PluginLoader - Detected Java version 11.0.10
13:51:05.279 [main] DEBUG com.tngtech.archunit.core.PluginLoader - Current Java version is compatible to JAVA_9 => Loading Plugin com.tngtech.archunit.core.importer.ModuleImportPlugin
13:51:05.407 [main] DEBUG com.tngtech.archunit.ArchConfiguration - No configuration found in classpath at archunit.properties => Using default configuration
... (logs telling which classes are being analysed) ...
... (then the tests I wanted to run actually run)...
This is a problem to me because this situation artificially increases the duration of my feedback loop when working in a Test-Driven Development setting: the ArchUnit analysis is usually much longer to run than the tests I actually meant to run.
What I've been able to work out so far regarding this issue
- Using fields or functions to declare the
@ArchTest
s has no effect on the issue; - Changing the
packages
attribute of@AnalyzeClasses
has no effect on the issue; - Using
archunit-junit4
instead ofarchunit-junit5
works as a workaround; - Violating the ArchUnit rules on purpose does not affect the overall tests results shown in IntelliJ IDEA.