Skip to content

hazendaz/javabean-tester

Repository files navigation

javabean-tester

Java CI Coverage Status Renovate enabled Maven Central Project Stats Apache 2

Latest Release

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.11.2</version>
  <scope>test</scope>
</dependency>

Or using Gradle:

testImplementation 'com.github.hazendaz:javabean-tester:2.11.2'

Information for other build frameworks can be found here.

Requires java 17+

Sites

Javabean Tester is a reflection based library for testing java beans. Effectively test constructors, clear, getters/setters, hashcode, toString, equals, and serializable are correct.

Left Codebox and fork network

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:

Documentation Status

Actively accepting pull requests for documentation of this library. Focus will only be on new builder pattern. Vast majority of examples exist in the test package.

Example Usage

JavaBeanTester.builder(Test.class, Extension.class).checkEquals().checkSerializable()
        .loadData().skipStrictSerializable().skip("FieldToSkip", "AnotherFieldToSkip").test();
JavaBeanTester.builder(Test.class).loadData().testEquals(instance1, instance2);
JavaBeanTester.builder(Test.class).testPrivateConstructor();

Check Equals will perform equality checks. This applies when hashcode, toString, and equals/canEqual are setup.

Check Serializable will perform a serialization check. This ensures that just because a class is marked as serializable that it really is serializable including children.

Load Data will load underlying data as best possible for basic java types.

Skip Strict Serializable will not perform a serialization check as this is only valid for POJOs currently.

Skip will skip all included elements from underlying getter/setter checks.

About

JavaBean Tester

Resources

License

Stars

Watchers

Forks

Sponsor this project

 

Packages

 
 
 

Contributors

Languages