public interface BeanVerifier
BeanVerifier.verifyBean(Company.class); // verify bean methods, equals/hashCode and toString
BeanVerifier.verifyBeans(Company.class, Employee.class);
BeanVerifier.forClass(Company.class)
.withSettings(settings -> settings.setDefaultIterations(12))
.withSettings(settings -> settings.addIgnoredProperty(Company::getName)) // exclude name property in bean getter/setter test
.verifyGettersAndSetters()
| Modifier and Type | Method and Description |
|---|---|
VerifierSettingsEditor |
editSettings()
Customizes bean verification settings.
|
static BeanVerifier |
forClass(Class<?> beanClass)
Start a fluent bean verification chain for the given beanClass
|
default void |
verify()
|
static void |
verifyBean(Class<?> beanClass)
Verify that given beanClass has valid bean getters/setters, equals/hashCode, and toString methods
|
static void |
verifyBeans(Class<?>... beanClasses)
Verify that given beanClasses have valid bean getters/setters, equals/hashCode, and toString methods
|
static void |
verifyBeansIn(Package packageObj)
Verify that bean classes in given packageObj have valid bean getters/setters, equals/hashCode, and toString methods
|
static void |
verifyBeansIn(String packageName)
Verify that bean classes in given packageName have valid bean getters/setters, equals/hashCode, and toString methods
|
BeanVerifier |
verifyEqualsAndHashCode()
Checks the bean's equals and hashCode methods.
|
BeanVerifier |
verifyGettersAndSetters()
Checks the bean's public getter and setter methods.
|
BeanVerifier |
verifyToString()
Checks that the bean overrides the default to Object::toString method.
|
BeanVerifier |
withSettings(Consumer<VerifierSettings> verifierSettingsEditor)
Customizes bean verification settings.
|
static BeanVerifier forClass(Class<?> beanClass)
static void verifyBean(Class<?> beanClass)
static void verifyBeans(Class<?>... beanClasses)
static void verifyBeansIn(String packageName)
static void verifyBeansIn(Package packageObj)
BeanVerifier withSettings(Consumer<VerifierSettings> verifierSettingsEditor)
BeanVerifier.forClass(Company.class)
.withSettings(settings -> settings.registerFactory(Employee.class, () -> createEmployee())
.withSettings(settings -> settings.setDefaultIterations(10))
VerifierSettingsEditor editSettings()
BeanVerifier.forClass(Company.class)
.editSettings() // start editing settings
.setDefaultIterations(12)
.addEqualsInsignificantProperty(Company::getId)
.registerFactory(Company.class, () -> company)
.addIgnoredProperty(Company::getName)
.edited() // finish editing settings and perform verifications
.verifyGettersAndSetters();
BeanVerifier verifyEqualsAndHashCode()
EqualsMethodTester,
HashCodeMethodTesterBeanVerifier verifyGettersAndSetters()
Each property is tested by:
Each property of a type is tested in turn. Each type is tested multiple times to reduce the risk of hard-coded values
within a getter or setter matching the random test values generated and the test failing to detect a bug.
BeanTesterBeanVerifier verifyToString()
ToStringMethodTesterdefault void verify()
Copyright © 2010–2020 meanbean. All rights reserved.