Search code examples
pax-exam

Pax-Exam @Configuration in test classes


In Pax-exam test classes. We have to provide the configuration as follows. to create the container.

@Configuration
public Option[] config() {
    setup();

    return options(
            mavenBundle().artifactId("testng").groupId("org.testng").versionAsInProject(),
            mavenBundle().artifactId("sample1").groupId("sample2").versionAsInProject(),
            mavenBundle().artifactId("sample3").groupId("sample4").versionAsInProject()

}

Instead of defining this in every test class, can't we provide a configuration to provision the container?..


Solution

  • You can use a ConfigurationFactory service. Or simply factor out your options to some static helper method and invoke this from the @Configuration method of your tests.