application test : ArchUnit - class dependency test
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package com.example.apptest.study;
|
||||
|
||||
import com.example.apptest.App;
|
||||
import com.tngtech.archunit.junit.AnalyzeClasses;
|
||||
import com.tngtech.archunit.junit.ArchTest;
|
||||
import com.tngtech.archunit.lang.syntax.ArchRuleDefinition;
|
||||
import com.tngtech.archunit.lang.syntax.elements.ClassesShouldConjunction;
|
||||
|
||||
import javax.persistence.Entity;
|
||||
|
||||
@AnalyzeClasses(packagesOf = App.class)
|
||||
public class ArchClassTests {
|
||||
|
||||
// @ArchTest
|
||||
// ClassesShouldConjunction controllerClassRule =
|
||||
// ArchRuleDefinition.classes().that().haveSimpleNameEndingWith("Controller")
|
||||
// .should().accessClassesThat().haveSimpleNameEndingWith("Service")
|
||||
// .orShould().accessClassesThat().haveSimpleNameEndingWith("Repository");
|
||||
|
||||
// @ArchTest
|
||||
// ClassesShouldConjunction repositoryClassRule =
|
||||
// ArchRuleDefinition.noClasses().that().haveSimpleNameEndingWith("Repository")
|
||||
// .should().accessClassesThat().haveSimpleNameEndingWith("Service")
|
||||
// .orShould().accessClassesThat().haveSimpleNameEndingWith("Controller");
|
||||
|
||||
@ArchTest
|
||||
ClassesShouldConjunction studyClassesRule =
|
||||
ArchRuleDefinition.classes().that().haveSimpleNameStartingWith("Study")
|
||||
.and().areNotEnums()
|
||||
.and().areNotAnnotatedWith(Entity.class)
|
||||
.should().resideInAnyPackage("..study..");
|
||||
}
|
||||
@@ -13,7 +13,7 @@ import org.junit.jupiter.api.Test;
|
||||
|
||||
// App.class 가 있는 패키지 선택
|
||||
@AnalyzeClasses(packagesOf = App.class)
|
||||
public class ArchJUnitTest {
|
||||
public class ArchJUnitTests {
|
||||
|
||||
// 룰 정의 후 테스트
|
||||
@ArchTest
|
||||
@@ -26,11 +26,13 @@ public class ArchJUnitTest {
|
||||
.should().accessClassesThat().resideInAPackage("..study..");
|
||||
|
||||
@ArchTest
|
||||
ClassesShouldConjunction memberPackageRule = ArchRuleDefinition.noClasses().that().resideInAPackage("..domain..")
|
||||
ClassesShouldConjunction memberPackageRule =
|
||||
ArchRuleDefinition.noClasses().that().resideInAPackage("..domain..")
|
||||
.should().accessClassesThat().resideInAnyPackage("..member..");
|
||||
|
||||
@ArchTest
|
||||
ClassesShouldConjunction domainPackageRule = ArchRuleDefinition.classes().that().resideInAPackage("..domain..")
|
||||
ClassesShouldConjunction domainPackageRule =
|
||||
ArchRuleDefinition.classes().that().resideInAPackage("..domain..")
|
||||
.should().onlyBeAccessed().byClassesThat().resideInAnyPackage("..study..", "..member..", "..domain..");
|
||||
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.example.apptest;
|
||||
package com.example.apptest.study;
|
||||
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.example.apptest;
|
||||
package com.example.apptest.study;
|
||||
|
||||
import org.junit.jupiter.api.extension.AfterTestExecutionCallback;
|
||||
import org.junit.jupiter.api.extension.BeforeTestExecutionCallback;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.example.apptest;
|
||||
package com.example.apptest.study;
|
||||
|
||||
import org.junit.jupiter.api.extension.AfterTestExecutionCallback;
|
||||
import org.junit.jupiter.api.extension.BeforeTestExecutionCallback;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.example.apptest;
|
||||
package com.example.apptest.study;
|
||||
|
||||
import org.junit.jupiter.api.Tag;
|
||||
import org.junit.jupiter.api.Test;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.example.apptest;
|
||||
package com.example.apptest.study;
|
||||
|
||||
import org.junit.jupiter.api.Test;
|
||||
import org.junit.jupiter.api.extension.ExtendWith;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.example.apptest;
|
||||
package com.example.apptest.study;
|
||||
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
@@ -1,4 +1,4 @@
|
||||
package com.example.apptest;
|
||||
package com.example.apptest.study;
|
||||
|
||||
import org.junit.jupiter.api.*;
|
||||
import org.junit.jupiter.api.condition.*;
|
||||
Reference in New Issue
Block a user