2

我想使用包含在依赖关系jar中的TestNG套件文件来执行集成测试。如何在没有解包依赖jar的情况下运行TestNG suite with failsafe?

details of setting up the pom.xml are discussed here

这里的POM文件我现在有。问题是,我需要定义一套文件中的一部分:

<?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>test</groupId> 
    <artifactId>test-runner</artifactId> 
    <version>1.0.0-SNAPSHOT</version> 

    <dependencies> 
    <dependency> 
     <groupId>${test.library.groupId}</groupId> 
     <artifactId>${test.library.artifactId}</artifactId> 
     <version>${test.library.version}</version> 
    </dependency> 
    <dependency> 
     <groupId>${test.library.groupId}</groupId> 
     <artifactId>${test.library.artifactId}</artifactId> 
     <version>${test.library.version}</version> 
     <classifier>tests</classifier> 
    </dependency> 
    </dependencies> 

    <build> 
    <plugins> 
     <plugin> 
     <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-failsafe-plugin</artifactId> 
     <version>2.18</version> 
     <executions> 
      <execution> 
      <goals> 
       <goal>integration-test</goal> 
       <goal>verify</goal> 
      </goals> 
      </execution> 
     </executions> 
     <configuration> 
      <suiteXmlFiles> 
      <suiteXmlFile>${test.suite}.xml</suiteXmlFile> <!-- <<< this is the issue --> 
      </suiteXmlFiles> 
      <dependenciesToScan> 
      <dependency>${test.library.groupId}:${test.library.artifactId}</dependency> 
      </dependenciesToScan> 
     </configuration> 
     </plugin> 
    </plugins> 
    </build> 
</project> 

的测试可以通过在詹金斯的工作参数提供值来执行:

-Dtest.library.groupId=com.example.test 
    -Dtest.library.artifactId=example 
    -Dtest.library.version=2.0.1 
    -Dtest.suite=smoke 

这一切工作正常,如果套件文件在本地是可用的,但我想使它只能在jar中使用套件文件(与测试类相同)。没有解包。

所以问题是:如何定义套件文件的位置(打包在依赖项中)?

这是问题的一部分:

<suiteXmlFile>[whatComesHere?]${test.suite}.xml</suiteXmlFile> 

我怎么能点保险/在被包含在试验瓶一套文件万无一失?或者这是不可能的,我只能为了能够运行特定的套件文件而解压缩jar文件?

回答

0

使用万无一失插件指定以下在配置部分属性:

 <groupId>org.apache.maven.plugins</groupId> 
     <artifactId>maven-surefire-plugin</artifactId> 
     <version>${version}</version> 
     <configuration> 
      <properties> 
      <property> 
       <name>testjar</name> 
       <value>your.test.jar</value> 
      </property> 
      <property> <!--use if testng.xml is not in root directory--> 
       <name>xmlpathinjar</name> 
       <value>resources/testng.xml</value> 
      </property> 
      </properties> 
     </configuration> 
相关问题