Question

I am running arquillian tests with junit and gradle. How do I choose which container gets started?

At the moment I am defining the container qualifier in a file with name arquillian.launch.

My arquillian.xml looks as follows:

<?xml version="1.0" encoding="UTF-8" ?>
<arquillian ...>
  <container qualifier="glassfish3-embedded" default="true">
    <configuration>
      ...
    </configuration>
  </container>
  <container qualifier="wls">
    <configuration>
      ...
    </configuration>
  </container>
</arquillian>

My build.gradle looks as follows:

[...]
configurations {
  glassfishEmbeddedTestRuntime { extendsFrom testRuntime }
  weblogic10RemoteTestRuntime { extendsFrom testRuntime }
}

dependencies {
  glassfishEmbeddedTestRuntime group: 'org.jboss.arquillian.container', name: 'arquillian-glassfish-embedded-3.1', version: '1.0.0.CR4'
  glassfishEmbeddedTestRuntime group: 'org.glassfish.main.extras', name: 'glassfish-embedded-all', version: libraryVersions.glassfish

  weblogic10RemoteTestRuntime group: 'org.jboss.arquillian.container', name: 'arquillian-wls-remote-10.3', version: '1.0.0.Alpha2' 
}

task glassfishEmbeddedTest(type: Test)

task weblogic10RemoteTest(type: Test)

tasks.withType(Test).matching({ t-> t.name.endsWith('Test') } as Spec).each { t ->
  t.classpath = project.configurations.getByName(t.name + 'Runtime') + project.sourceSets.main.output + project.sourceSets.test.output
}

How can I expand the definition for weblogic10RemoteTest, so that I can choose the container, and I don't have to edit the arquillian.launch file or the arquillian.xml file by changing the xml before executing the tests?

I thought about doing it like here: https://github.com/seam/solder/blob/develop/testsuite/pom.xml#L123

But I don't know the equivalent of this statement in gradle.

Était-ce utile?

La solution

The POM you linked to sets system properties for the JVM running the tests. You can do the same in Gradle by configuring your Test task(s):

test { // or: tasks.withType(Test) {
    systemProperty "one", "foo"
    systemProperty "two", "bar"
}

(Note that Gradle always runs tests in a separate JVM.)

For further information, see Test in the Gradle Build Language Reference.

Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top