Package org.tudalgo.algoutils.reflect
Class TestUtils
java.lang.Object
org.tudalgo.algoutils.reflect.TestUtils
A utility class used for JUnit tests which provides reflective access to some properties and
assertions.
-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptionstatic voidassertModifier(int expected, int actual, String name) Tests whether the modifiers are correct.static voidassertModifier(int expected, Class<?> clazz) Tests whether the modifiers of a class are correct.static voidassertModifier(int expected, Constructor<?> constructor) Tests whether the modifiers of a constructor are correct.static voidassertModifier(int expected, Field attribut) Tests whether the modifiers of a field are correct.static voidassertModifier(int expected, Method method) Tests whether the modifiers of a method are correct.static inteditDistance(String s1, String s2) Calculates the similarity (a number within 0 and 1) between two strings.static Class<?>[]getClasses(String packageName) Scans all classes accessible from the context class loader which belong to the given package and subpackages.static booleanReturnstrueifTestCycleResolver.getTestCycle()does not returnnull.static doublesimilarity(String s1, String s2) Calculates the similarity (a number within 0 and 1) between two strings.
-
Field Details
-
BRIDGE
public static final int BRIDGE- See Also:
-
VARARGS
public static final int VARARGS- See Also:
-
SYNTHETIC
public static final int SYNTHETIC- See Also:
-
ANNOTATION
public static final int ANNOTATION- See Also:
-
ENUM
public static final int ENUM- See Also:
-
MANDATED
public static final int MANDATED- See Also:
-
-
Method Details
-
assertModifier
Tests whether the modifiers are correct.- Parameters:
expected- the expected modifier countactual- the actual modifier countname- the name of the field to be checked
-
assertModifier
Tests whether the modifiers of a class are correct.- Parameters:
expected- the expected modifier countclazz- the class to be checked
-
assertModifier
Tests whether the modifiers of a method are correct.- Parameters:
expected- the expected modifier countmethod- the method to be checked
-
assertModifier
Tests whether the modifiers of a constructor are correct.- Parameters:
expected- the expected modifier countconstructor- the constructor to be checked
-
assertModifier
Tests whether the modifiers of a field are correct.- Parameters:
expected- the expected modifier countattribut- the field to be checked
-
similarity
Calculates the similarity (a number within 0 and 1) between two strings.- Parameters:
s1- the first string used for the calculation of the similaritys2- the second string used for the calculation of the similarity- Returns:
- the similarity
-
editDistance
Calculates the similarity (a number within 0 and 1) between two strings.- Parameters:
s1- the first string used for the calculation of the similaritys2- the second string used for the calculation of the similarity- Returns:
- the calculated similarity (a number within 0 and 1) between two strings.
- See Also:
-
getClasses
Scans all classes accessible from the context class loader which belong to the given package and subpackages.- Parameters:
packageName- The base package name- Returns:
- the found classes
- Throws:
IOException- if an I/O Exception occurs
-
isAutograderRun
public static boolean isAutograderRun()ReturnstrueifTestCycleResolver.getTestCycle()does not returnnull.- Returns:
trueifTestCycleResolver.getTestCycle()does not returnnull
-