2012-12-13 22 views
0

我有了一個測試項目的依賴Maven項目。我想在這個項目上運行TestNG的:運行TestNG的上一個maven test依賴

<groupId>com.myGroup</groupId> 
<artifactId>assembly</artifactId> 
<version>1.0.0-SNAPSHOT</version> 

<dependencies> 
    <dependency> 
     <groupId>org.testng</groupId> 
     <artifactId>testng</artifactId> 
     <version>6.4</version> 
    </dependency> 
    <dependency> 
     <groupId>com.myGroup</groupId> 
     <artifactId>myArtifact</artifactId> 
     <version>1.0.0-SNAPSHOT</version> 
     <type>test-jar</type> 
    </dependency> 
</dependencies> 

<build> 
    <plugins> 
     <plugin> 
      <groupId>org.apache.maven.plugins</groupId> 
      <artifactId>maven-surefire-plugin</artifactId> 
      <version>2.12.4</version> 
      <configuration> 
      <test>MyTest</test> 
       <suiteXmlFiles> 
        <suiteXmlFile>test-suites/all-test.xml</suiteXmlFile> 
       </suiteXmlFiles> 
      </configuration> 
     </plugin> 
    </plugins> 
</build> 

但是當我運行MVN清潔上述項目安裝沒有任何反應。是否有可能設置maven-surefire-plugin來運行testNG。二進制依賴?

編輯:

此:

http://softwaremavens.blogspot.dk/2009/09/running-tests-from-maven-test-jar-in.html

似乎即期。如果可以直接從依賴項運行代碼而不是解壓它,那可能會很好。

回答

0

這是現在可以使用Maven神火2.15版。只需以下類型的配置添加到萬無一失插件:

<build> 
    <plugin> 
    <groupId>org.apache.maven.plugins</groupId> 
    <artifactId>maven-surefire-plugin</artifactId> 
    <version>2.15</version> 
    <configuration> 
     <dependenciesToScan> 
     <dependency>com.group.id:my-artifact</dependency> 
     <dependency>com.group.id:my-other-artifact</dependency> 
     </dependenciesToScan> 
     ... 
    </configuration> 
    ... 
    </plugin> 
    ... 
</build> 

你也應該申報相關內容部分的實際依賴性:

<dependencies> 
    <dependency> 
    <groupId>com.group.id</groupId> 
    <artifactId>my-artifact</artifactId> 
    <type>test-jar</type> 
    <version>1.1</version> 
    <scope>test</scope> 
    </dependency> 
    <dependency> 
    <groupId>com.group.id</groupId> 
    <artifactId>my-other-artifact</artifactId> 
    <type>test-jar</type> 
    <version>1.1</version> 
    <scope>test</scope> 
    </dependency> 
</dependencies>