Usually it's just a matter of adding:
@RunWith(FeaturesRunner.class)
@Features(
{ TransactionalFeature.class, CoreFeature.class }
)
@RepositoryConfig(cleanup = Granularity.METHOD)
And injecting the session:
@Inject
protected CoreSession session;
And getting rid of the setUp/tearDown if they only do standard stuff.
If setUp does some deployBundle / deployContrib, you'll have to turn them into @Deploy / @LocalDeploy, like:
@Deploy(
{ "org.nuxeo.runtime.management",
"org.nuxeo.ecm.core.management",
"org.nuxeo.ecm.core.management.test" }
)
@LocalDeploy(
{ "org.nuxeo.ecm.core.test.tests:test-CoreExtensions.xml",
"org.nuxeo.ecm.core.test.tests:test-security-policy-contrib.xml" }
)
If you have one test method that needs to do specific deploys, the pattern is:
@Inject
protected RuntimeHarness harness;
@Test
public void test() throws Exception
{
harness.deployContrib("org.nuxeo.ecm.core.test.tests", "test-PostCommitListeners.xml");
...
harness.undeployContrib("org.nuxeo.ecm.core.test.tests", "test-PostCommitListeners.xml");
}
Please make sure that you always have TransactionalFeature in your Features, it's how Nuxeo actually runs and non-transactional stuff usually has problems with inter-session visibility.