Version 2



    This document outlines what you need to setup your Gradle project to use Arquillian and Wildfly for testing.  In this scenario, WildFly is "embedded" - run in the same JVM.




    Gradle 1.11

    WildFly 8.0.0.Final

    Java 1.7


    Project Setup


    |-- bin
    |   `-- test
    |       |-- TestCDI.class
    |       `-- TestEJB.class
    |-- build.gradle
    |-- src
    |   `-- test
    |       `-- java
    `-- wildfly-8.0.0.Final


    As mentioned above, it needs a copy of WildFly to run the test.




    description = 'test project'
    ext.jbossHome = hasProperty('jbossHome') ? jbossHome : "${rootDir}/wildfly-8.0.0.Final"
    apply plugin: 'java'
    sourceCompatibility = 1.7
    targetCompatibility = 1.7
    repositories {
        maven { url '' }
        maven { url '' }
        maven { url '' }
    dependencies {
        compile 'org.wildfly:wildfly-spec-api:8.0.0.Final'
        compile 'org.slf4j:slf4j-simple:1.7.7'
        testCompile 'junit:junit:4.11'
        testCompile 'org.jboss.shrinkwrap.resolver:shrinkwrap-resolver-depchain:2.1.0'
        testCompile 'org.jboss.arquillian:arquillian-bom:1.1.2.Final-wildfly-1'
        testCompile 'org.jboss.arquillian.junit:arquillian-junit-container:1.1.2.Final-wildfly-1'
        testRuntime 'org.jboss.logging:jboss-logging:3.1.4.GA'
         * Embedded means it runs in the same JVM, it still needs the full installation
        testRuntime 'org.wildfly:wildfly-arquillian-container-embedded:8.0.0.Final'
    test {
        jvmArgs '-XX:MaxPermSize=256m'
         * Installation of JBOSS to use for testing, this can be set here
         * or in the arquillian.xml.
        environment 'JBOSS_HOME', rootProject.jbossHome
         * WildFly embedded default logging
        systemProperty 'java.util.logging.manager', 'org.jboss.logmanager.LogManager'



    TestCDI and TestEJB


    public class TestCDI {
        Logger log = LoggerFactory.getLogger(TestCDI.class);
        private TestEJB testEjb;
        public static WebArchive createDeployment() {
            File[] dependencies = Maven.resolver().resolve(
            WebArchive war = ShrinkWrap.create(WebArchive.class, "test.war")
                    .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
            return war;
        public void testCDI() throws Exception {



    public class TestEJB {
        public String helloWorld() {
            return "hello world";


    Running test

    ➜  test  gradle clean test
    :clean UP-TO-DATE
    :compileJava UP-TO-DATE
    :processResources UP-TO-DATE
    :classes UP-TO-DATE
    warning: Supported source version 'RELEASE_6' from annotation processor '' less than -source '1.7'
    1 warning
    :processTestResources UP-TO-DATE
    INFO  [org.jboss.modules] JBoss Modules version 1.3.0.Final
    INFO  [org.jboss.msc] JBoss MSC version 1.2.0.Final
    INFO  [] JBAS015899: WildFly 8.0.0.Final "WildFly" starting
    INFO  [] JBAS015888: Creating http management service using socket-binding (management-http)
    INFO  [org.xnio] XNIO version 3.2.0.Final
    INFO  [org.xnio.nio] XNIO NIO Implementation Version 3.2.0.Final
    INFO  [org.jboss.remoting] JBoss Remoting version 4.0.0.Final
    INFO  [] JBAS016300: Activating JacORB Subsystem
    INFO  [] JNDI bindings for session bean named TestEJB in deployment unit deployment "test.war" are as follows:
    INFO  [org.jboss.weld.deployer] JBAS016005: Starting Services for CDI deployment: test.war
    INFO  [org.jboss.weld.Version] WELD-000900: 2.1.2 (Final)
    INFO  [org.jboss.weld.deployer] JBAS016008: Starting weld service for deployment test.war
    INFO  [org.wildfly.extension.undertow] JBAS017534: Registered web context: /test
    INFO  [] JBAS018559: Deployed "test.war" (runtime-name : "test.war")
    INFO  [] JBAS015950: WildFly 8.0.0.Final "WildFly" stopped in 140ms
    Total time: 17.98 secs



    Look at our log for result


    ➜  test  more wildfly-8.0.0.Final/standalone/log/server.log
    2014-04-29 12:33:48,777 INFO  [test.TestCDI] (default task-1) hello world
    2014-04-29 12:44:59,142 INFO  [test.TestCDI] (default task-2) hello world





    I did not use arquillian.xml in this test but here is a sample if you are interested.  Like I mentioned in the build.gradle you can put the location of wildfly here or as a system property.  Look also at the commented supported property names, everything else you can control by modifying standalone.xml


    <?xml version="1.0" encoding="UTF-8"?>
    <arquillian xmlns=""
        <container qualifier="jboss" default="true">
            <!-- Supported property names: [managementPort, username, managementAddress, bundlePath, managementProtocol, 
                        cleanServerBaseDir, jbossHome, password, modulePath] -->
                <property name="jbossHome">wildfly-8.0.0.Final/</property>



    Happy Testing