Class StructuralLevenshtein
java.lang.Object
io.github.valentinherrmann.levenshtein.StructuralLevenshtein
Utility class for generating structural validation tests using wrapper objects.
Provides methods to create JUnit DynamicTests that verify class structures with various levels of detail.
Student code is only touched inside the executables of the generated tests (never while the list of tests is built), so every check runs under the supervision of the enclosing Ares test.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic enumEnumeration defining the level of detail for structural test generation. -
Method Summary
Modifier and TypeMethodDescriptionstatic List<org.junit.jupiter.api.DynamicTest> structuralTestFactory(StructuralLevenshtein.DetailLevel detailsLevel, boolean skipEmpty, ClassWrapper<?>... classWrappers) LikestructuralTestFactory(DetailLevel, ClassWrapper[]), but chooses whether groups without wrappers get a test.static List<org.junit.jupiter.api.DynamicTest> structuralTestFactory(StructuralLevenshtein.DetailLevel detailsLevel, ClassWrapper<?>... classWrappers) Factory method for creating dynamic structural tests based on class wrappers.static voidstructuralTestTemplate(List<? extends Wrapper<?>> wrappers) Template method for structural testing that checks wrapper existence states.
-
Method Details
-
structuralTestTemplate
Template method for structural testing that checks wrapper existence states. Collects all wrappers with MISSING or DEVIATES states and fails if any are found. A wrapper whose check itself fails unexpectedly is reported instead of aborting the whole test.- Parameters:
wrappers- the list of wrappers to verify
-
structuralTestFactory
public static List<org.junit.jupiter.api.DynamicTest> structuralTestFactory(StructuralLevenshtein.DetailLevel detailsLevel, ClassWrapper<?>... classWrappers) Factory method for creating dynamic structural tests based on class wrappers. Generates JUnit DynamicTests organized according to the specified detail level, in a deterministic order. Groups without wrappers (e.g.Attributes[X]for a class without attributes) get no test, because such a test would always pass, also for an untouched template.- Parameters:
detailsLevel- the level of detail for test organizationclassWrappers- the class wrappers to generate tests for- Returns:
- a list of DynamicTest objects ready to be used in a @TestFactory method
- See Also:
-
structuralTestFactory
public static List<org.junit.jupiter.api.DynamicTest> structuralTestFactory(StructuralLevenshtein.DetailLevel detailsLevel, boolean skipEmpty, ClassWrapper<?>... classWrappers) LikestructuralTestFactory(DetailLevel, ClassWrapper[]), but chooses whether groups without wrappers get a test.- Parameters:
detailsLevel- the level of detail for test organizationskipEmpty-true(default of the other overload): no test for a group without wrappers;false: such a group gets a test that always passes (the previous behaviour)classWrappers- the class wrappers to generate tests for- Returns:
- a list of DynamicTest objects ready to be used in a @TestFactory method
-