Class StaticFieldsInvariantRule
java.lang.Object
com.carrotsearch.randomizedtesting.rules.StaticFieldsInvariantRule
- All Implemented Interfaces:
org.junit.rules.TestRule
A
TestRule
that ensures static, reference fields of the suite class
(and optionally its superclasses) are cleaned up after a suite is completed.
This is helpful in finding out static memory leaks (a class references
something huge but is no longer used).- See Also:
-
Nested Class Summary
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final boolean
static final long
private final long
-
Constructor Summary
ConstructorsConstructorDescriptionBy default useDEFAULT_LEAK_THRESHOLD
as the threshold and count in superclasses.StaticFieldsInvariantRule
(long leakThresholdBytes, boolean countSuperclasses) -
Method Summary
-
Field Details
-
DEFAULT_LEAK_THRESHOLD
public static final long DEFAULT_LEAK_THRESHOLD- See Also:
-
leakThreshold
private final long leakThreshold -
countSuperclasses
private final boolean countSuperclasses
-
-
Constructor Details
-
StaticFieldsInvariantRule
public StaticFieldsInvariantRule()By default useDEFAULT_LEAK_THRESHOLD
as the threshold and count in superclasses. -
StaticFieldsInvariantRule
public StaticFieldsInvariantRule(long leakThresholdBytes, boolean countSuperclasses)
-
-
Method Details
-
apply
public org.junit.runners.model.Statement apply(org.junit.runners.model.Statement s, org.junit.runner.Description d) - Specified by:
apply
in interfaceorg.junit.rules.TestRule
-
accept
- Returns:
- Return
false
to exclude a given field from being counted. By default final fields are rejected.
-