Friday 15 April 2016

Mean Bean: BeanTester: Customize the configuration

By using ConfigurationBuilder() class, you can create Configuration instance, which is passed as an argument to testBean method.

Configuration config = new ConfigurationBuilder().iterations(55).ignoreProperty("name").build();
                 
BeanTester beanTester = new BeanTester();
beanTester.testBean(Employee.class, config);


In above case, Employee.class method is tested by using given configuration (it performs 55 iterations and ignore name property).
public class Employee {
  private String name;
  private int id;

  public String getName() {
    return name.toUpperCase();
  }

  public void setName(String name) {
    this.name = name;
  }

  public int getId() {
    return id;
  }

  public void setId(int id) {
    this.id = id;
  }

}

import org.junit.Test;
import org.meanbean.test.BeanTester;
import org.meanbean.test.Configuration;
import org.meanbean.test.ConfigurationBuilder;

public class TestBean {

  @Test
  public void testEmployee() {
    Configuration config = new ConfigurationBuilder()
    .iterations(55).ignoreProperty("name").build();
    
    BeanTester beanTester = new BeanTester();
    beanTester.testBean(Employee.class, config);
  }
}



Previous                                                 Next                                                 Home

No comments:

Post a Comment