https://kotlinlang.org logo
#konsist
Title
# konsist
m

Mirco Franzek

12/11/2023, 12:10 PM
Hey #konsist, is there any way to test that a layer DOES NOT depend on another layer? Or alternatively, that no class in package x imports one from package y?
p

PoisonedYouth

12/11/2023, 12:16 PM
You mean as addition to the
dependsOn
in the
assertArchitecture?
m

Mirco Franzek

12/11/2023, 12:17 PM
Yea maybe, dependsNotOn - but I'm asking for any solution with the current version
this would be useful for modulith architecture testing
p

PoisonedYouth

12/11/2023, 12:41 PM
I also asked for this in the past but this is not possible with
assertArchitecture
and the defined layers. My workarount is:
Copy code
@Test
    fun `package A should not depend on package B`() {
        projectScope
            .files
            .withPackage("..packageA..")
            .assertFalse {
                it.hasImportWithName(
                   "..packageB..
                )
            }
    }
👍 3
m

Mirco Franzek

12/11/2023, 12:46 PM
Ah, files, I always tried classes 🙂 thanks!
p

PoisonedYouth

12/11/2023, 12:47 PM
🙂
2 Views