Utilitaires for testing
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.



Utilitaires for testing

Wiki page of this test tools.

This project give some lite tools for test unit writing. It's base on framework JUnit, DBUnit and Mockito.

If you're using the GitHub for Mac, simply sync your repository and you'll see the new branch.

JUnit features :

public class ParameterizedTest {

  private final MyService service = new MyService();

  public static Collection<Object[]> datas1() {
    final Collection<Object[]> datas = new ArrayList<Object[]>();

    datas.add(new Object[] { "Paul", "Hello, Paul", 1, new Object[] { "test", Double.valueOf(2.54689) } });
    datas.add(new Object[] { "Jack", "Hello, Jack", 2, new String[] {} });
    datas.add(new Object[] { "my name is Patty  !", "Hello, my name is Patty  !", 5, null });

    return datas;

  public void testGreet(final String name, final String expected, final int cpt, final Object[] vals) {
    System.out.println(cpt + ", " + ToStringBuilder.reflectionToString(vals, ToStringStyle.SHORT_PREFIX_STYLE));

Mockito features :

Based on JUnit rule

public class MockingRuleTest {

  public MockingRule rule = MockingRule.init();

  private MyService mock;

  private MyService spy;

  public void testRule() {


DBUnit features :

Load datas with @DataSet, automaticly inject EntityManager if defined int class :

public class DBUnitRuleTest {

  private EntityManager em;

  public void testLoadOthers() {
    final MyEntity entity = em.find(MyEntity.class, 20l);
    assertEquals(Long.valueOf(20), entity.getId());
    assertEquals("Pierre", entity.getName());

@DataSet can be defined for the entire class and/or for a specific method.

To activate DBUnit, 3 ways a JUnit rule :

  public DBUnitRule dbUnitRule = DBUnitRule.init();

an abstract class :

public class AbstractDBUnitTestTest extends AbstractDBUnitTest {

a runner :

public class DBUnitRunnerTest {

You can define the rollback strategy with @Transactionnal. You can redefined JPA config with @JpaConfig (by default the unit persistence name is 'pu-test'). note that you can not even change the persistence.xml file name, but soon I hope :)

Support or Contact

Create an issue on Guthub, or a pull request ;)