我已经在网络上找到了一些知识点,但是无法将它们整合在一起来解决这个具体案例 . This answer似乎是一个非常好的开始,但它专门处理EAR依赖 .

我的(简化)maven项目结构如下:

parent
 |__domain     (a jar)
 |__domain-it  (integration tests for the domain module)
 |__web        (a war; depends on domain)
 |__web-it     (integration tests for the web module)

我正在寻找以下解决方案:

  • 我想要进行Arquillian集成测试,测试 web 模块包含的代码 .

  • 这些测试将包含在单独的 web-it 模块中 .

  • 由于 web 模块依赖于 domain 模块,因此 web-it 集成测试还需要具有类路径上 domain 模块的代码 .

  • domainweb 都依赖于某些第三方库,例如 org.apache.commons:commons-lang3 ,这在测试类路径中也是必需的 .

  • 测试需要在命令行上通过Maven运行,并通过junit直接在Eclipse中运行 .

我在Glassfish 3.1.2上运行 .

任何帮助,将不胜感激 . 我觉得这个场景没有特定的Arquillian文档很奇怪,因为我觉得它很常见 . 也许我错过了一些基本的东西?

以下是我迄今为止尝试过的一些内容:

  • 使 web-it 依赖于 web ,将以下内容添加到 web-it/pom.xml ,如下所示:
<dependency>  
    <groupId>${project.groupId}</groupId>
    <artifactId>web</artifactId>
    <version>${project.version}</version>
    <scope>test</scope>
    <type>war</type>
</dependency>

但是这不包括测试类路径上的 web 中的任何类

<plugin>
    <groupId>org.apache.maven.plugins</groupId>
    <artifactId>maven-war-plugin</artifactId>
    <configuration>
        <attachClasses>true</attachClasses>
    </configuration>
</plugin>

web-it/pom.xml

<dependency>  
    <groupId>${project.groupId}</groupId>
    <artifactId>web</artifactId>
    <version>${project.version}</version>
    <scope>test</scope>
    <classifier>classes</classifier>
</dependency>

这包括测试类路径中 web 的类,但没有传递依赖项(例如 commons-lang3 ) .

我也考虑过了,但还没试过:

  • 使用Maven Warpath plugin,如this answer中所述 . 当这与m2e / eclipse一起使用时似乎存在一些问题,我希望能够从eclipse运行我的集成测试 .

  • 以某种方式使用_1432283来创建基于项目pom的Arquillian部署 . 我不确定这将如何在eclipse中运行(即在maven之外),但它也意味着我需要有效地部署整个WAR,而不仅仅是它的一部分 - 我喜欢并希望Arquillian的一个功能能够保存 .