Fork me on GitHub

Quick Start

  1. Add the Bean Matchers dependency to your Maven project:
    <dependency>
        <groupId>com.google.code.bean-matchers</groupId>
        <artifactId>bean-matchers</artifactId>
        <version>0.14</version>
        <scope>test</scope>
    </dependency>
  2. Test your bean:
    import static com.google.code.beanmatchers.BeanMatchers.*;
    import static org.hamcrest.CoreMatchers.allOf;
    import static org.hamcrest.MatcherAssert.assertThat;
    
    public class MyBeanTest {
    
        @Test
        public void testBean() {
            assertThat(MyBean.class, allOf(
                    hasValidBeanConstructor(),
                    hasValidGettersAndSetters(),
                    hasValidBeanHashCode(),
                    hasValidBeanEquals(),
                    hasValidBeanToString()
            ));
        }
    
    }