我正在尝试使用 PAX Exam 设置测试,如下所示:
@ExamReactorStrategy(PerMethod.class)
public class AbstractTest {
@Configuration
public Option[] config() {
return options(
junitBundles(),
/* PAX Logging */
mavenBundle("org.ops4j.pax.logging", "pax-logging-api", "1.7.2"),
mavenBundle("org.ops4j.pax.logging", "pax-logging-service", "1.7.2"),
/* Apache Felix Config Admin */
mavenBundle("org.apache.felix", "org.apache.felix.configadmin", "1.8.0"),
/* Eclipse Gemini dependencies */
mavenBundle().groupId("org.aopalliance").artifactId("com.springsource.org.aopalliance").versionAsInProject(),
mavenBundle().groupId("org.springframework").artifactId("org.springframework.aop").versionAsInProject(),
mavenBundle().groupId("org.springframework").artifactId("org.springframework.beans").versionAsInProject(),
mavenBundle().groupId("org.springframework").artifactId("org.springframework.context").versionAsInProject(),
mavenBundle().groupId("org.springframework").artifactId("org.springframework.core").versionAsInProject(),
/* Eclipse Gemini */
mavenBundle("org.eclipse.gemini.blueprint", "gemini-blueprint-core", GEMINI_VERSION),
mavenBundle("org.eclipse.gemini.blueprint", "gemini-blueprint-extender", GEMINI_VERSION),
mavenBundle("org.eclipse.gemini.blueprint", "gemini-blueprint-io", GEMINI_VERSION),
/* Other bundles */;
}
@Before
public void setUp() throws Exception {
....
}
}
@RunWith(PaxExam.class)
public class MyTest extends AbstractTest {
@Inject
private MyObject myObject;
@Test
public void testOne() {
...
}
}
@Before
由于某种原因,没有调用带有注释的方法。
谢谢,米凯尔
编辑:我使用的 PAX 考试依赖项是:
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-container-native</artifactId>
<version>${pax.exam.version}</version>
<scope>test</scope>
<exclusions>
<exclusion>
<groupId>org.osgi</groupId>
<artifactId>org.osgi.core</artifactId>
</exclusion>
</exclusions>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-junit4</artifactId>
<version>${pax.exam.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-link-mvn</artifactId>
<version>${pax.exam.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.url</groupId>
<artifactId>pax-url-aether</artifactId>
<version>${url.version}</version>
<scope>test</scope>
</dependency>
我使用 PAX EXAM 3.4.0 版。