Java Arquillian测试在本地服务器上运行,而不是在远程Wildfly服务器上运行
我试图用arquillian框架测试我的应用程序。因此,我配置了pom和arquillian.xml以在wildfly远程容器中运行我的测试用例。即使我在arquillian.xml中指定了远程地址,测试用例也在本地wildfly服务器中运行。我已经配置了服务器配置文件,并使用远程wildfly服务器配置文件运行了测试 测试类Java Arquillian测试在本地服务器上运行,而不是在远程Wildfly服务器上运行,java,integration-testing,wildfly-8,jboss-arquillian,Java,Integration Testing,Wildfly 8,Jboss Arquillian,我试图用arquillian框架测试我的应用程序。因此,我配置了pom和arquillian.xml以在wildfly远程容器中运行我的测试用例。即使我在arquillian.xml中指定了远程地址,测试用例也在本地wildfly服务器中运行。我已经配置了服务器配置文件,并使用远程wildfly服务器配置文件运行了测试 测试类 @RunWith(Arquillian.class) public class BasicTest { @Deployment public static JavaAr
@RunWith(Arquillian.class)
public class BasicTest {
@Deployment
public static JavaArchive createDeployment() {
return ShrinkWrap.create(JavaArchive.class).addClass(Greeter.class)
.addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml");
}
@Inject
private Greeter greeter;
@Test
public void shouldBeAbleTo() {
assertEquals("Hello, aliens!", greeter.createGreeting("aliens"));
}
}
pom.xml
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.aerogear</groupId>
<artifactId>arquillian-wildfly-example</artifactId>
<packaging>jar</packaging>
<version>0.0.1</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<version.org.jboss.arquillian>1.1.5.Final</version.org.jboss.arquillian>
<version.org.wildfly>8.1.0.Final</version.org.wildfly>
<version.junit>4.11</version.junit>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
</plugin>
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-dependency-plugin
</artifactId>
<versionRange>
[2.1,)
</versionRange>
<goals>
<goal>unpack</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencyManagement>
<dependencies>
<!-- Arquillian BOM (Bill Of Materials). -->
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>${version.org.jboss.arquillian}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<!-- JUnit regression testing framework. -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${version.junit}</version>
</dependency>
</dependencies>
</dependencyManagement>
<profiles>
<!-- Arquillian WildFly remote profile -->
<profile>
<id>arq-widlfly-remote</id>
<dependencies>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-arquillian-container-remote</artifactId>
<version>8.2.0.Final</version>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
</profiles>
<dependencies>
<!-- JUnit regression testing framework. -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<!-- JUnit Container Implementation for the Arquillian Project -->
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.protocol</groupId>
<artifactId>arquillian-protocol-servlet</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<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">
<!-- Sets the protocol which is how Arquillian talks and executes the tests inside the container -->
<defaultProtocol type="Servlet 3.0" />
<!-- Configuration to be used when the WidlFly remote profile is active -->
<container qualifier="widlfly-remote">
<configuration>
<property name="managementAddress">xxxxx</property>
<property name="managementPort">xxxx</property>
<property name="username">xxxx</property>
<property name="password">xxxx</property>
</configuration>
</container>
4.0.0
org.jboss.aerogear
arquillian野蝇示例
罐子
0.0.1
UTF-8
1.1.5.最终版本
8.1.0.1最终版本
4.11
maven编译器插件
3.1
1.7
1.7
maven surefire插件
2.17
org.eclipse.m2e
生命周期映射
1.0.0
org.apache.maven.plugins
maven依赖插件
[2.1,)
打开
org.jboss.arquillian
阿奎利安bom
${version.org.jboss.arquillian}
进口
聚甲醛
朱尼特
朱尼特
${version.junit}
广域远程
野生蝇
wildfly arquillian集装箱遥控器
8.2.0.1最终版本
测试
朱尼特
朱尼特
org.jboss.arquillian.junit
arquillian junit容器
测试
org.jboss.arquillian.protocol
arquillian协议servlet
测试
arquillian.xml
<?xml version="1.0"?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.aerogear</groupId>
<artifactId>arquillian-wildfly-example</artifactId>
<packaging>jar</packaging>
<version>0.0.1</version>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<version.org.jboss.arquillian>1.1.5.Final</version.org.jboss.arquillian>
<version.org.wildfly>8.1.0.Final</version.org.wildfly>
<version.junit>4.11</version.junit>
</properties>
<build>
<pluginManagement>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>3.1</version>
<configuration>
<source>1.7</source>
<target>1.7</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
</plugin>
<!--This plugin's configuration is used to store Eclipse m2e settings
only. It has no influence on the Maven build itself. -->
<plugin>
<groupId>org.eclipse.m2e</groupId>
<artifactId>lifecycle-mapping</artifactId>
<version>1.0.0</version>
<configuration>
<lifecycleMappingMetadata>
<pluginExecutions>
<pluginExecution>
<pluginExecutionFilter>
<groupId>
org.apache.maven.plugins
</groupId>
<artifactId>
maven-dependency-plugin
</artifactId>
<versionRange>
[2.1,)
</versionRange>
<goals>
<goal>unpack</goal>
</goals>
</pluginExecutionFilter>
<action>
<ignore></ignore>
</action>
</pluginExecution>
</pluginExecutions>
</lifecycleMappingMetadata>
</configuration>
</plugin>
</plugins>
</pluginManagement>
</build>
<dependencyManagement>
<dependencies>
<!-- Arquillian BOM (Bill Of Materials). -->
<dependency>
<groupId>org.jboss.arquillian</groupId>
<artifactId>arquillian-bom</artifactId>
<version>${version.org.jboss.arquillian}</version>
<scope>import</scope>
<type>pom</type>
</dependency>
<!-- JUnit regression testing framework. -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>${version.junit}</version>
</dependency>
</dependencies>
</dependencyManagement>
<profiles>
<!-- Arquillian WildFly remote profile -->
<profile>
<id>arq-widlfly-remote</id>
<dependencies>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-arquillian-container-remote</artifactId>
<version>8.2.0.Final</version>
<scope>test</scope>
</dependency>
</dependencies>
</profile>
</profiles>
<dependencies>
<!-- JUnit regression testing framework. -->
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<!-- JUnit Container Implementation for the Arquillian Project -->
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.protocol</groupId>
<artifactId>arquillian-protocol-servlet</artifactId>
<scope>test</scope>
</dependency>
</dependencies>
<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">
<!-- Sets the protocol which is how Arquillian talks and executes the tests inside the container -->
<defaultProtocol type="Servlet 3.0" />
<!-- Configuration to be used when the WidlFly remote profile is active -->
<container qualifier="widlfly-remote">
<configuration>
<property name="managementAddress">xxxxx</property>
<property name="managementPort">xxxx</property>
<property name="username">xxxx</property>
<property name="password">xxxx</property>
</configuration>
</container>
xxxxx
xxxx
xxxx
xxxx
但是测试用例正在127.0.0.1:9990 wildfly服务器上运行,而不是在arquillian.xml中指定的远程wildfly服务器上运行。我必须执行/更改什么配置。请帮助我。您需要告诉arquillian要使用哪个arquillian.xml容器限定符运行,因为您可以在同一xml文件中定义许多限定符。如果您只有一个元素,并且只需要一个元素。您可以在该元素上定义default=true属性,在这种情况下,除非定义了其他任何内容,否则Arquillian将使用该属性
<container qualifier="widlfly-remote" default="true">
...
</container>
...
否则,您可以在Maven Surefire执行中将-Darquillian.launch=widlfly remote定义为系统属性,以动态设置它
基本上,在当前设置中,您没有告诉Arquillian要使用哪个限定符,这意味着它将使用类路径上容器适配器的默认值来运行(这就是您看到使用127.0.0.1的原因).我在maven surefire中将-Darquillian.launch=widlfly remote定义为系统属性。现在我遇到了类似java.lang.RuntimeException的错误:无法创建类org.jboss.arquillian.test.impl.EventTestRunGeneradaptor的新实例,请参阅cause.at org.jboss.arquillian.test.spi.SecurityActions.newInstance(SecurityActions.java:170)你有该异常的其余部分吗?尝试升级到Arquillian 1.1.8.Final。查看该异常是否有更多信息。感谢回复。我升级1.1.8版本不成功。我已尝试使用seleniumhq(www.seleniumhq.org)测试网站。这对我来说很有用,而且很简单。哪一个更适合arquillian selenium或selenium来测试web界面?不确定为什么它会失败,您的示例pom和测试用例在WildFly 8.2.0.Final上运行良好。可能尝试解包一个新的WildFly实例。。