Mittwoch, 4. Juni 2014

Fast creation of test data



Do you know this problem? You spend too much time into developing unit tests, because you have to fill complex beans with test data? The PodamFactory offers a very easy way to create test data Pojos with reflection:


import de.havre.CpeBo;
import org.junit.Test;
import uk.co.jemos.podam.api.PodamFactory;
import uk.co.jemos.podam.api.PodamFactoryImpl;

public class PojoTest
{

  CommitmentConfigStateHandler sut;

  PodamFactory factory = new PodamFactoryImpl();

  @Test
  public void testProcessConfigState_success() throws Exception
  {
    ComplexBean pojo = factory.manufacturePojo(ComplexBean.class);
    sut.methodToTest(testDataBean);
  }
}

Maven dependency:

<dependency>
  <groupId>uk.co.jemos.podam</groupId>
  <artifactId>podam</artifactId>
  <version>3.6.0.RELEASE</version>
  <scope>test</scope>
</dependency>

Keine Kommentare:

Kommentar veröffentlichen