I want to test some code with different persistence units. Therefor I have written two identical TestNG test classes that only differ in the name of the persistence unit that I pass to Persistence#createEntityManagerFactory to get the correct factory.
This call is in a setup method annotated with `@BeforeClass“
@BeforeClass
public void setupClass() {
emf = Persistence.createEntityManagerFactory("test-eclipselink-h2");
em = emf.createEntityManager();
// init with some dummy data
// ... some more initialization
}
What are the options to execute this test class with different persistence-units? It would be sufficient to have the names hardcoded in test classes, there is no need to specify them externally.
1 Answer