Example Usage

public class BeanTest extends TestCase {

        private BeanRunner beanRunner = new BeanRunner();
        public void testTestBean() throws Exception {
                SimpleBean bean = new SimpleBean();

Things checked

  • Getter/setter pairs - A getter without a setter is not called and neither is a setter without a getter.
  • Serializable - If the object implements Serializable then it is serialized and deserialized to ensure all member of the class are also Serializable.

Setting values

In order to call a setter, Bean Runner needs to have an instance of the value being set. If a no-arg constuctor exists, it will be used to create an instance. If not, an instance needs to be provided.

BeanRunner beanRunner = new BeanRunner();
Calendar cal = Calendar.getInstance();
beanRunner.addTestValue(Calendar.class, cal);

Excluding Properties

Sometimes it is desireable to exclude properties from being tested. This might include setters that have side effects or do range checking on values.

public void testExcludeProperty() throws Exception {