简体   繁体   English

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

[英]Testing with Arquillian, how to share Arquillian.xml?

How can the Arquillian configuration file Arquillian.xml be shared between projects and team members? 如何在项目和团队成员之间共享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>

The problem is this points to specific locations on the the disk, and different team members use Wildfly in different locations. 问题在于这指向磁盘上的特定位置,并且不同的团队成员在不同的位置使用Wildfly。

In addition we must duplicate Arquillian.xml for each project that uses it. 此外,我们必须为每个使用Arquillian.xml的项目复制Arquillian.xml。

We use Arquillian for Maven testing (which could inject the values) and JUnit tests within Eclipse (which cannot inject them). 我们将Arquillian用于Maven测试(可以注入值)和Eclipse中的JUnit测试(不能注入值)。

Any ideas how to do this? 任何想法如何做到这一点?

Since there is already Maven support and structure then you can make use of Maven properties and replace of place holder values. 由于已经有了Maven支持和结构,因此您可以使用Maven属性并替换占位符值。 It is simple 很简单

I guess your Arquillian.xml is under src/test/resources/arquillian.xml right? 我猜你的Arquillian.xml在src / test / resources / arquillian.xml下,对吗? Then you can replace the absolute values with properties. 然后,您可以用属性替换绝对值。

 <configuration>
    <property name="jbossHome">${jboss.home}</property>
</configuration>

The above property can be either defined in the properties section of your pom or can be overridden during mvn executuon using -Djboss.home=C:\\myPath 上面的属性可以在pom的属性部分中定义,也可以在mvn执行期间使用-Djboss.home = C:\\ myPath覆盖

In order though this thing to work, you want Maven automatically for each developer when is about to package arquillian.xml to replace this place-holder ${jboss.home} with a value, that we have either defined on top in the properties section or we have passed it from the command line. 为了使该功能正常运行,当希望将arquillian.xml打包为一个占位符$ {jboss.home}替换为值时,我们希望Maven自动为每个开发人员使用,该值已在属性部分的顶部定义或者我们已经从命令行传递了它。 This is done through the resource filtering functionality 这是通过资源过滤功能完成的

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

     <testResources>
</build>

See the simple examples here 这里看到简单的例子

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM