Using PODAM is easy. You can either declare it as a Maven dependency or, used it with Spring or, if you need to customise its behaviour, fork PODAM from GitHub and build it yourself.
If you are using Maven and want to use PODAM directly in your project, you can declare it as a Maven dependency (always ensure you are using the latest version):
<dependency> <groupId>uk.co.jemos.podam</groupId> <artifactId>podam</artifactId> <version>[latest.version]</version> <!-- <scope>test</scope> --> </dependency>
You can also use PODAM with Spring:
# Define your Spring app context <?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd"> <!-- The definition of PODAM factory --> <bean id="podamFactory" class="uk.co.jemos.podam.api.PodamFactoryImpl" /> </beans>
# Use Podam Factory in your code /** * */ package uk.co.jemos.podam.test.unit.integration; import javax.annotation.Resource; import org.junit.Assert; import org.junit.Before; import org.junit.Test; import org.springframework.test.context.ContextConfiguration; import org.springframework.test.context.junit4.AbstractJUnit4SpringContextTests; import uk.co.jemos.podam.api.PodamFactory; import uk.co.jemos.podam.test.dto.SimplePojoToTestSetters; /** * @author mtedone * */ @ContextConfiguration(locations = {"classpath:podam-test-appContext.xml"}) public class PodamFactoryInjectionIntegrationTest extends AbstractJUnit4SpringContextTests { /** The Podam Factory */ @Resource private PodamFactory factory; @Before public void init() { Assert.assertNotNull("The PODAM factory cannot be null!", factory); Assert.assertNotNull("The factory strategy cannot be null!", factory.getStrategy()); } @Test public void testSimplePojo() { SimplePojoToTestSetters pojo = factory .manufacturePojo(SimplePojoToTestSetters.class); Assert.assertNotNull("The pojo cannot be null!", pojo); ...etc } }
Please note that the data provider strategy cannot be changed upon instantiation. If you want to use a different data provider strategy, you'll need to create a new instance of PodamFactory. This has been decided to preserve thread-safety and immutability of PodamFactory.
The following pre-requisites must be satisfied in order to build PODAM:
Once the pre-requisites have been satisfied, do the following:
# To build PODAM jar and execute the tests mvn clean install # To build this documentation and Javadocs mvn clean site:site