generated from SmartOperatingBlock/kotlin-template-project
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCleanArchitectureTest.kt
33 lines (30 loc) · 1.4 KB
/
CleanArchitectureTest.kt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
/*
* Copyright (c) 2023. Smart Operating Block
*
* Use of this source code is governed by an MIT-style
* license that can be found in the LICENSE file or at
* https://opensource.org/licenses/MIT.
*/
package architecture
import com.tngtech.archunit.core.importer.ClassFileImporter
import com.tngtech.archunit.library.Architectures.layeredArchitecture
import io.kotest.core.spec.style.StringSpec
class CleanArchitectureTest : StringSpec({
"Test that the layers of Clean Architecture are respected" {
layeredArchitecture()
.consideringAllDependencies()
.layer("entity").definedBy("..entity..")
.layer("usecase").definedBy("..usecase..")
.layer("application").definedBy("..application..")
.layer("infrastructure").definedBy("..infrastructure..")
.whereLayer("entity").mayOnlyBeAccessedByLayers("usecase", "application", "infrastructure")
.whereLayer("usecase").mayOnlyBeAccessedByLayers("application", "infrastructure")
.whereLayer("application").mayOnlyBeAccessedByLayers("infrastructure")
.whereLayer("infrastructure").mayNotBeAccessedByAnyLayer()
.check(
ClassFileImporter()
.withImportOption { !it.contains("/test/") } // ignore tests classes
.importPackages("entity", "usecase", "application", "infrastructure"),
)
}
})