2013-01-09 50 views
0

我正在做一個非常簡單的Pax考試考試。OSGI Pax考試在maven上運行但不在IDE上的簡單測試

當使用maven「mvn verify」運行它時,它是成功的。 使用我的IDE運行它時,出現以下錯誤。

任何人都知道我是否缺少一個jar或這是一個錯誤?

感謝,

java.lang.Exception: No tests found matching Method checkBundles(test.TestPaxExam) from [email protected] 
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> 
+0

IntelliJ和PaxExam還存在問題嗎? – kevcodez

回答

0

我沒有看到任何可疑的你測試或在你的POM中。看起來像一個IntelliJ問題 - 在你的測試類中不存在簽名爲checkBundles(test.TestPaxExam)的方法,所以JUnit是正確的抱怨。

+0

我在一臺使用ubuntu的新電腦上試了這個相同的測試項目,我無法在沒有在pom.xml中添加部分的情況下編譯它(已經在第一篇文章中更新過)。仍然是同樣的問題。 – lleclerc

相關問題