2012-07-31 36 views
2

有沒有人試過用Bndtools來運行PaxExam Junit測試,並且可以給我一些建議?我自己試了一下,但沒有Maven,下載所有的依賴關係是一種痛苦。使用PaxExam和Bndtools

什麼我迄今所做的:從中央Maven的

  1. 下載PaxExam依賴關係(有什麼比較容易的方法?)
  2. 創建一個包含CNF/bnd.bnd
  3. 所有依賴屬性添加屬性來構建路徑,我想編寫測試
  4. 執行測試失敗,BC更依賴失蹤做回1:d

我想使用PaxExam,因爲它們只生成測試報告,但它們不是真正的「Junit測試」,因此它更容易與Ant Junit任務一起用作Bndtools的集成測試。

後來情景:

  1. 建設項目,哈德森和Ant
  2. 哈德森也應該執行Junit的Ant任務,其中失敗的測試應停止建設進程以及

上述場景已經工作與正常的Junit4測試沒有運行OSGi環境,但現在我想做集成測試。

有人可以幫助我嗎?

問候。

+0

你有沒有考慮過簡單地使用Maven與Maven Bundle插件而不是ant + bndtools?這對我很有效。 – 2012-08-01 08:51:50

+0

在我看來,Bndtools比MBP更好,因爲它在某些情況下使開發更容易。所以是的,我看了一下,但決定去Bndtools;) – 2012-08-01 09:13:01

+0

爲什麼bnd的測試報告不是'真正的'單元測試? – 2013-08-02 06:39:18

回答

4

即使您不使用Maven構建項目,仍然可以使用它來下載maven-artifacts及其傳遞依賴項。要做到這一點,你首先必須install Maven。然後,創建一個空目錄,並在該目錄內創建一個名爲pom.xml的文件。對於大同考試,這應該是這樣的:

<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>test</groupId> 
    <artifactId>test</artifactId> 
    <version>0.0.1-SNAPSHOT</version> 
    <packaging>pom</packaging> 
    <properties> 
     <exam.version>2.5.0</exam.version> 
     <url.version>1.4.2</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.29</version> 
      <scope>test</scope> 
     </dependency> 
     <dependency> 
      <groupId>ch.qos.logback</groupId> 
      <artifactId>logback-classic</artifactId> 
      <version>0.9.29</version> 
      <scope>test</scope> 
     </dependency> 
    </dependencies> 
</project> 

我採取的依賴列表從Pax Exam documentation。然後,打開命令行,導航到您創建pom.xml的目錄,然後執行以下命令:

mvn dependencies:copy-dependencies 

(假定您已經安裝的Maven這樣的命令mvn是可用的形式命令行)。現在maven將獲取您在pom.xml中指定的依賴項的所有傳遞依賴項,並將它們存儲在默認情況下target/dependency中。

+0

有趣的故事:我已經想過要這樣做,就像你在你的答案中描述的那樣)所以你從我+1得到:)但是,也許還有其他方法。希望 – 2012-08-01 09:56:30

+0

我接受了你的答案,因爲它似乎是唯一的方法:)所以對我來說這是最有幫助的。祝賀;) – 2012-08-04 10:51:19

+0

你可以提供一個獎勵你的問題,以獲得更多的意見,並鼓勵人們思考更難。 – 2012-08-05 18:58:01