This is a Java JUnit testing utility to allow easy testing of getter/setter methods for properties.
The implementation was originally written by Scott Leberknight and discussed in Do You Unit Test Getters and Setters? It was again discussed by myself, Josef Betancourt, at Testing getter/setter using JUnit
Lately the original source code archive is not available so I decided to create this project.
There are many discussions regarding the usefulness or return on investment of unit testing property access in Java.
One of the issues is that Java could be criticized that unlike other languages, it does not have real Object properties, just programming idioms such as method names. So, a method named getValue() may be accessing a property or invoking a web service.
This property access utility makes this a non-issue, kind of.
One of the unit tests shows how easy it is to use.
/**
* Test method for {@link PropertyAsserter#assertBasicGetterSetterBehavior(Object)}
*/
@Test
public final void shouldAssertBasicGetterSetterBehaviorObject() {
PropertyAsserter.assertBasicGetterSetterBehavior(new TargetClass1());
}
- JUnit to compile, test.
- JMockit to run the JUnit tests for the utility itself.
- Gradle or Maven to build.
- SLF4J
Target JVM: 1.6
- IDE: Eclipse 4.3
- OS: Windows 7 64bit Professional
- CPU: AMD quad
The original code did not have a license, but this fork does.
This project is released under version 2.0 of the Apache License.
The original author can contact me to indicate if this is not fair use.