Testing framework: Is it possible to deploy a contribution on per method base?

Hi,

I've seen some examples from the Nuxeo source , where the deployment is done within the test methods through deployContrib (…) (old testing framework?). I would like to do the same using annotations on per method base. Or is it by design to deploy contributions on per class base?

Thanks.

[example]

@RunWith(FeaturesRunner.class)  
@Features({CoreFeature.class})  
[..]
public class TestClass {

    @Test  
    @Deploy({"org.my.service:OSGI-INF/my-test-contrib.xml"}) /*nice to have*/
    public void myTest() throws Exception {
        ...;
    }
0 votes

1 answers

1108 views

ANSWER



Hi Edgar,

Using Deploy annotations on method does not do anything. In fact you should not be able to do this. We need to fix the target of the Deploy and LocalDeploy annotation. But what you can do is inject the test harness like this:

@RunWith(FeaturesRunner.class)
@Features({CoreFeature.class})
public class TestClass {
    @Inject
    protected RuntimeHarness harness.

    @Test
    public void myTest() throws Exception {
        // deploy the complete bundle
        harness.deployBundle("org.my.service");
        // deploy a specific contribution
        harness.deployContrib("org.my.service","OSGI-INF/my-test-contrib.xml");
    }
}
0 votes