|
Project Information
|
The ProblemWriting tests for JavaBeans™ is...
However, we often build larger systems on top of JavaBeans™, so we need to be sure they're behaving correctly. What's more, if our project uses a code-coverage threshold, our build will fail if we don't test them. The Missing PointJavaBeans™ are supposed to be machine-processable! The SolutionJavaBeanRunner automatically tests your JavaBean properties using the power of !JUnit. Writing tests with JavaBeanRunner is...
Writing tests for a bean can be done in only a few lines of code, using only a couple of simple annotations. Moreover, JavaBeanRunner will automatically fail if you add new, untested, properties to your bean. ExampleTo test this simple bean: public class Bean {
private String name;
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}You need only write the following test code: @RunWith(JavaBeanRunner.class)
@Bean(Bean.class)
public BeanTest {
@Property("name")
public String name = "name";
}Resources
|