我试图让一个简单的测试用例运行:
我只想在新下载的Wildfly容器中通过mvn test
运行一个简单的测试用例。
docs对嵌入式案例说, maven-dependency-plugin 的unpack
目标可以用于下载Wildfly并自动解压缩。
我想让容器托管确保为测试用例提供单独的JVM,由 Arquillian 本身管理。
1)我可以在我的test/resource/arquillian.xml
通过:
<container qualifier="arquillian-wildfly8-managed" default="true">
<configuration>
<property name="jbossHome">target/wildfly-8.1.0.Final</property>
<property name="modulePath">target/wildfly-8.1.0.Final/modules</property>
</configuration>
</container>
2)另一种方法是在pom文件中配置 surefire-plugin 的系统属性:
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
<configuration>
<property>
<name>jboss.home</name>
<value>${project.basedir}/target/wildfly-8.1.0.Final</value>
</property>
<property>
<name>module.path</name>
<value>${project.basedir}/target/wildfly-8.1.0.Final/modules</value>
</property>
</systemProperties> </configuration> </plugin>
[ERROR]
/home/me/playground/arquillian-tutorial/src/test/java/org/arquillian/example/ATest.java:[3,19]
error: package javax.inject does not exist
...即找不到课程。
摘自我的pom文件:
<build>
<plugins>
<plugin>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.3.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-surefire-plugin</artifactId>
<version>2.17</version>
</plugin>
</plugins>
</build>
<dependencyManagement>
<dependencies>
<dependency>
<groupId>org.jboss.arquillian</groupId>
<version>1.1.5.Final</version>
<artifactId>arquillian-bom</artifactId>
<scope>import</scope>
<type>pom</type>
</dependency>
</dependencies>
</dependencyManagement>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>4.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.jboss.arquillian.junit</groupId>
<artifactId>arquillian-junit-container</artifactId>
<!-- <version>1.1.5.Final</version> -->
<scope>test</scope>
</dependency>
</dependencies>
<profile>
<id>arquillian-wildfly8-managed</id>
<dependencies>
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-6.0</artifactId>
<version>3.0.1.Final</version>
<type>pom</type>
<scope>test</scope>
</dependency>
<!-- Required by jboss-javaee-6.0:3.0.2.Final (https://issues.jboss.org/browse/JBBUILD-708) -->
<dependency>
<groupId>xalan</groupId>
<artifactId>xalan</artifactId>
<version>2.7.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-arquillian-container-managed</artifactId>
<version>8.1.0.Final</version>
<scope>test</scope>
</dependency>
</dependencies>
<build>
<pluginManagement>
<plugins>
<plugin>
<!-- You need the maven dependency plugin to download locally a zip
with the server, unless you provide your own, it will download under the
/target directory -->
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>2.8</version>
<executions>
<execution>
<id>unpack</id>
<phase>process-test-classes</phase>
<goals>
<goal>unpack</goal>
</goals>
<configuration>
<artifactItems>
<artifactItem>
<groupId>org.wildfly</groupId>
<artifactId>wildfly-dist</artifactId>
<version>8.1.0.Final</version>
<type>zip</type>
<overWrite>false</overWrite>
<outputDirectory>target</outputDirectory>
</artifactItem>
</artifactItems>
</configuration>
</execution>
</executions>
</plugin>
</plugins>
</pluginManagement>
</build>
</profile>
我很困惑。我无法找到一个简单的设置来以适当的方式通过Arquillian / Wildfly运行测试用例。你有任何想法,提示或链接吗?
答案 0 :(得分:0)
我强烈建议您不要自动下载包含服务器的.zip文件,而是自己提供服务器实例。
我可以在test / resource / arquillian.xml
中完成
是的,这就是它的方法。
另一种方法是配置surefire-plugin的
没有必要。只是不要忘记将Arquillian.xml文件作为pom中的测试资源提供:
<testResources>
<testResource>
<directory>path/to/resources</directory>
</testResource>
您可以发布测试用例代码吗?我很想看看你的@Deployment
方法。
您错过了对测试的EE实现依赖性。
<dependency>
<groupId>org.jboss.spec</groupId>
<artifactId>jboss-javaee-7.0</artifactId>
<version>1.0.0.Final</version>
<type>pom</type>
<scope>provided</scope>
</dependency>