In general one of the advantages of using JEMM is that you do not need it running to unit test. If the agent is not running the entities behave the same but are not saved. However sometimes you will want to make sure that JEMM transforms the class correctly, or you are using a JEMM specific class that requires a Store to be placed into the Session.
To make JEMM "go" you need to do two things:
Depending on how you want to run your unit tests the approach needed changes.
With Maven 2 the settings can be placed into the POM, enhancing the junit surefire plugin to reference the agent. Within the plugins section the following configuration option will do the necessary enhancement. Its
<project> ... <build> <plugins <plugin> <groupId>org.apache.maven.plugins</groupId> <artifactId>maven-surefire-plugin</artifactId> <configuration> <argLine>-javaagent:"${settings.localRepository} /org/sourceforge/jemm/jemm/0.1-SNAPSHOT/jemm-0.1-SNAPSHOT.jar"</argLine> </configuration> </plugin> </plugins> </build> ... </project>
Change your normal junit task call to add a JVM argument as shown below. You also need the classpath setup with all of JEMMs dependencies.
... <junit fork="yes"> <jvmarg value="-javaagent:lib/jemm-0.1-SNAPSHOT.jar"/> ... </junit> ...