You can download source binaries from our releases page and release binaries from Maven central
Alternatively you can pull it using Maven:
<dependency>
<groupId>com.github.hazendaz</groupId>
<artifactId>javabean-tester</artifactId>
<version>2.12.1</version>
<scope>test</scope>
</dependency>Or using Gradle:
testImplementation 'com.github.hazendaz:javabean-tester:2.12.1'Information for other build frameworks can be found here.
Requires java 17+
Javabean Tester is a reflection based library for testing java beans. Effectively test constructors, clear, getters/setters, hashcode, toString, equals, and serializable are correct.
Portions of the initial baseline (getter/setter test) were contributed by Rob Dawson (codebox).
This project has since evolved into a full-featured version and is the primary maintained fork.
Pull requests and issues are welcome; the original CodeBox version exists separately and lacks the additional features here.
See historical discussion here:
The fluent builder is the supported entry point for configuring tests.
Run the standard bean checks:
JavaBeanTester.builder(Test.class).test();Add equals, hashCode, toString, and canEqual verification:
JavaBeanTester.builder(Test.class).checkEquals().loadData().test();Test two existing instances:
JavaBeanTester.builder(Test.class).loadData().testEquals(instance1, instance2);Skip selected bean properties:
JavaBeanTester.builder(Test.class).checkEquals().loadData().skip("fieldToSkip").test();Use an explicit extension type when you do not want the generated one:
JavaBeanTester.builder(Test.class, Extension.class).checkEquals().test();Test a private constructor:
JavaBeanTester.builder(Test.class).testPrivateConstructor();checkEquals()enables equals/hashCode/toString/canEqual verification.checkSerializable()fails fast when the class under test is not serializable and validates serializable round-tripping.loadData()asks the tester to populate nested values when sample data is needed.skipStrictSerializable()relaxes the equality assertion performed after serialization for complex object graphs.skip("propertyName")excludes specific bean properties from getter/setter checks.
