Add the following dependencies to your pom.xml file to get started using Needle:


<dependency>
    <groupId>de.akquinet.jbosscc</groupId>
    <artifactId>jbosscc-needle</artifactId>
    <version>2.1</version>
    <scope>test</scope>
</dependency>
    

Implementing your first Needle Test:


public class UserDaoTest {

    @Rule
    public DatabaseRule databaseRule = new DatabaseRule();

    @Rule
    public NeedleRule needleRule = new NeedleRule(databaseRule);

    @ObjectUnderTest
    private UserDao userDao;

    @Test
    public void testFindByUsername() throws Exception {
        final User user = new UserTestdataBuilder(
        databaseRule.getEntityManager()).buildAndSave();

        User userFromDb =
            userDao.findBy(user.getUsername(), user.getPassword());

        Assert.assertEquals(user.getId(), userFromDb.getId());
    }
}
    

For the documentation and more examples please refer to the Needle Documentation.