使用Arquillian进行测试,如何共享Arquillian.xml?

Poo*_*ool 2 java testing junit jboss-arquillian

如何在项目和团队成员之间共享Arquillian配置文件Arquillian.xml?

<arquillian xmlns="http://jboss.org/schema/arquillian"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="
    http://jboss.org/schema/arquillian
    http://jboss.org/schema/arquillian/arquillian_1_0.xsd">
<container qualifier="jbossas-managed-wildfly-8" default="true">
    <configuration>
        <property name="jbossHome">C:\test\wildfly-8.1.0.Final</property>
        <property name="javaVmArguments">-Djboss.socket.binding.port-offset=2 -Xmx512m -XX:MaxPermSize=128m</property>
        <property name="managementPort">9992</property>
    </configuration>
</container>
Run Code Online (Sandbox Code Playgroud)

问题是这指向磁盘上的特定位置,不同的团队成员在不同位置使用Wildfly.

此外,我们必须为使用它的每个项目复制Arquillian.xml.

我们使用Arquillian进行Maven测试(可以注入值)和Eclipse中的JUnit测试(不能注入它们).

任何想法如何做到这一点?

jav*_*apo 5

由于已经有Maven支持和结构,因此您可以使用Maven属性并替换占位符值.很简单

我想你的Arquillian.xml在src/test/resources/arquillian.xml下吗?然后,您可以使用属性替换绝对值.

 <configuration>
    <property name="jbossHome">${jboss.home}</property>
</configuration>
Run Code Online (Sandbox Code Playgroud)

上面的属性可以在你的pom的属性部分中定义,也可以在mvn executuon中使用-Djboss.home = C:\ myPath覆盖

为了使这个东西能够正常工作,你需要Maven自动为每个开发人员打包arquillian.xml时用一个值替换这个占位符$ {jboss.home},我们已经在属性部分的顶部定义了或者我们从命令行传递了它.这是通过资源过滤功能完成的

 <build>
     <testResources>
        <testResource>
            <directory>src/test/resources</directory>
            <filtering>true</filtering>
         </testResource>

     <testResources>
</build>
Run Code Online (Sandbox Code Playgroud)

请参阅此处的简单示例