OSGiPax考试简单测试在maven上运行,但不在IDE上运行
我正在做一个非常简单的Pax考试 在使用maven“mvn verify”运行它时,它是成功的。 在使用IDE运行它时,出现以下错误 有人知道我是丢了一个罐子还是这是个虫子吗 谢谢OSGiPax考试简单测试在maven上运行,但不在IDE上运行,osgi,integration-testing,pax-exam,Osgi,Integration Testing,Pax Exam,我正在做一个非常简单的Pax考试 在使用maven“mvn verify”运行它时,它是成功的。 在使用IDE运行它时,出现以下错误 有人知道我是丢了一个罐子还是这是个虫子吗 谢谢 java.lang.Exception: No tests found matching Method checkBundles(test.TestPaxExam) from org.junit.internal.requests.ClassRequest@1a19012 at org.junit.internal.
java.lang.Exception: No tests found matching Method checkBundles(test.TestPaxExam) from org.junit.internal.requests.ClassRequest@1a19012
at org.junit.internal.requests.FilterRequest.getRunner(FilterRequest.java:37)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:43)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:195)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:63)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
这是我的测试课:
package test;
import static org.junit.Assert.*;
import static org.ops4j.pax.exam.CoreOptions.*;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.ops4j.pax.exam.Option;
import org.ops4j.pax.exam.junit.Configuration;
import org.ops4j.pax.exam.junit.JUnit4TestRunner;
import org.osgi.framework.BundleContext;
import javax.inject.Inject;
@RunWith(JUnit4TestRunner.class)
public class TestPaxExam {
@Inject
public BundleContext bc;
@Configuration
public Option[] config() {
return options(
junitBundles()
);
}
@Test
public void checkBundles() {
assertNotNull(bc);
}
}
这是我的pom.xml:
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>TestPaxExam</groupId>
<artifactId>TestPaxExam</artifactId>
<version>1.0</version>
<properties>
<exam.version>2.5.0</exam.version>
<url.version>1.4.0</url.version>
</properties>
<dependencies>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-container-native</artifactId>
<version>${exam.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-junit4</artifactId>
<version>${exam.version}</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.ops4j.pax.exam</groupId>
<artifactId>pax-exam-link-mvn</artifactId>
<version>${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>
<dependency>
<groupId>org.apache.felix</groupId>
<artifactId>org.apache.felix.framework</artifactId>
<version>3.2.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-core</artifactId>
<version>0.9.20</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>ch.qos.logback</groupId>
<artifactId>logback-classic</artifactId>
<version>0.9.20</version>
<scope>test</scope>
</dependency>
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
</plugins>
</build>
</dependencies>
</project>
4.0.0
TestPaxExam
TestPaxExam
1
2.5.0
1.4.0
org.ops4j.pax.exam
pax考试容器本机
${exam.version}
测试
org.ops4j.pax.exam
pax-exam-junit4
${exam.version}
测试
org.ops4j.pax.exam
pax考试链接mvn
${exam.version}
测试
org.ops4j.pax.url
乙醚
${url.version}
测试
org.apache.felix
org.apache.felix.framework
3.2.2
测试
回写
回溯堆芯
0.9.20
测试
回写
回归经典
0.9.20
测试
maven编译器插件
1.7
1.7
我在您的测试或POM中没有发现任何可疑之处。看起来像是IntelliJ的问题-您的测试类中不存在签名为checkBundles(test.TestPaxExam)
的方法,因此JUnit有理由抱怨。我使用ubuntu在一台新计算机上尝试了相同的测试项目,如果不在pom.xml中添加该部分(在第一篇文章中已经对其进行了更新),我就无法编译它。还是一样的问题。你对IntelliJ和PaxExam还有问题吗?