Pool
Pool

Reputation: 12342

Testing with Arquillian, how to share Arquillian.xml?

How can the Arquillian configuration file Arquillian.xml be shared between projects and team members?

<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.

In addition we must duplicate Arquillian.xml for each project that uses it.

We use Arquillian for Maven testing (which could inject the values) and JUnit tests within Eclipse (which cannot inject them).

Any ideas how to do this?

Upvotes: 2

Views: 3321

Answers (1)

javapapo
javapapo

Reputation: 1342

Since there is already Maven support and structure then you can make use of Maven properties and replace of place holder values. It is simple

I guess your Arquillian.xml is under src/test/resources/arquillian.xml right? 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

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. 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

Upvotes: 5

Related Questions