版本:
eclipse: 4.2.0
seam: 2.3.0.Final
jboss-as: 7.1.0.Final
当前ftc项目pom.xml中的dependency已经包含了arquiilian依赖,所以不用再从官网上复制大片xml到自己的pom.xml中了。但要想在eclipse中执行单元测试还需要一点点改动:
我们首先在cn.ftc.test包下写一个测试类,代码如下:
package cn.ftc.test; import org.jboss.arquillian.container.test.api.Deployment; import org.jboss.arquillian.junit.Arquillian; import org.jboss.shrinkwrap.api.ShrinkWrap; import org.jboss.shrinkwrap.api.asset.EmptyAsset; import org.jboss.shrinkwrap.api.spec.JavaArchive; import org.junit.Assert; import org.junit.Test; import org.junit.runner.RunWith; @RunWith(Arquillian.class) public class ExcelProcessorTest { @Deployment public static JavaArchive createDeployment() { return ShrinkWrap.create(JavaArchive.class) .addClass(ExcelProcessorTest.class) .addAsManifestResource(EmptyAsset.INSTANCE, "beans.xml"); } @Test public void should_create_greeting() { System.out.println("hello"); } }
<container qualifier="jboss" default="true"> <configuration> <property name="jbossHome">你的JBoss安装目录</property> </configuration> </container>
<profile> <id>arq-jbossas-7-managed</id> <activation> <property> <name>arquillian</name> <value>jbossas-managed-7</value> </property> </activation> <dependencies> <dependency> <groupId>org.jboss.as</groupId> <artifactId>jboss-as-arquillian-container-managed</artifactId> <version>7.1.1.Final</version> <!-- 添加这一行 --> <scope>test</scope> </dependency> </dependencies>
<profile> <id>arq-jbossas-7-remote</id> <activation> <property> <name>arquillian</name> <value>jbossas-remote-7</value> </property> </activation> <dependencies> <dependency> <groupId>org.jboss.as</groupId> <artifactId>jboss-as-arquillian-container-remote</artifactId> <version>7.1.1.Final</version> <!-- 添加此行 --> <scope>test</scope> </dependency> </dependencies>