我用junit和gradle运行arquillian测试。如何选择启动哪个容器?</ p>
目前,我正在名为arquillian.launch
的文件中定义容器限定符。
我的arquillian.xml
如下所示:
<?xml version="1.0" encoding="UTF-8" ?>
<arquillian ...>
<container qualifier="glassfish3-embedded" default="true">
<configuration>
...
</configuration>
</container>
<container qualifier="wls">
<configuration>
...
</configuration>
</container>
</arquillian>
我的build.gradle
如下所示:
[...]
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
}
如何扩展weblogic10RemoteTest
的定义,以便我可以选择容器,而不必编辑arquillian.launch
文件或arquillian.xml
文件,方法是更改执行测试前的xml?
我想这样做:https://github.com/seam/solder/blob/develop/testsuite/pom.xml#L123
但我不知道gradle中这句话的等价物。
答案 0 :(得分:1)
您链接的POM为运行测试的JVM设置系统属性。您可以通过配置Test
任务:
test { // or: tasks.withType(Test) {
systemProperty "one", "foo"
systemProperty "two", "bar"
}
(请注意,Gradle始终在单独的JVM中运行测试。)
有关详细信息,请参阅Gradle Build Language Reference中的Test
。