UtilsVerifier is a pure Java library that can be used in Junit tests to verify that Utility class is properly defined.
By default verification includes:
- class having only one private constructor
- class being final
- class having no instance fields
- class having no instance methods
- class having no static mutable fields
UtilsVerifier.forClass(ClassToTest.class).verify();
It's possible to disable one or more of the default verification checks by using set of "suppress" methods.
UtilsVerifier.forClass(ClassToTest.class)
.suppressFinalClassCheck(true)
.suppressOnlyOneConstructorCheck(true)
.verify();
If the tested class constructor should throw an exception when used it's possible to specify the type of the exception.
UtilsVerifier.forClass(ClassToTest.class)
.withConstructorThrowing(DesiredException.class)
.verify();
To use library with Gradle
dependencies {
compile 'com.github.karczews:utilsverifier:1.0.0'
}
or using Maven:
<dependency>
<groupId>com.github.karczews</groupId>
<artifactId>utilsverifier</artifactId>
<version>1.0.0</version>
</dependency>