我如何通过将整个 war 部署到 WildFly embedded 来设置 arquillian 来测试 Maven war 项目?

How do I setup arquillian to test a maven war project by deploying the entire war to WildFly embedded?

我想在嵌入式 WildFly 实例上对我的 war 进行宏观(不是微观!)黑盒测试。

我的 maven 项目是这样的

<project>
  ...
  <packaging>war</packaging>

  <!-- Lots of classes in src/main/webapp and files in src/main/webapp -->
  <dependencies>
    <!-- Lots of compile/runtime dependencies that change very frequently -->
    <!-- Lots of test dependencies that change very frequently -->
  </dependencies>
</project>

我的 arquillian 测试需要满足以下要求:

理论上,Arquillian 的 Maven 解析器、嵌入式容器、@RunAsClient、maven failsafe 插件、一些 arquillian.xml 魔法和许多 maven 魔法都是可能的。但在实践中,我无法让这些东西一起工作,我也找不到任何文档来适当地涵盖这种情况,所以我希望有人能清楚地展示他们如何一起工作。

听起来绝对像是 ShrinkWrap Resolver 的案例Maven Importer (not to be confused with the Maven Resolver). Here 是一些显示其用法的测试。

我有一个独立示例,仅针对 Gradle Importer ( I know you're using maven ), but the test construction is similiar here.

我目前没有一个完整的示例可以公开地与 @RunAsClient 和 Maven Importer 一起使用,但我有一个项目将它们与 Graphene 一起使用,并且这种组合确实有效:)。一般来说,测试应该是这样的:

@RunWith(Arquillian.class)
public class SomeControllerIT {

    @Deployment
    public static WebArchive createDeployment() {
        return ShrinkWrap.create(MavenImporter.class).loadPomFromFile("pom.xml").importBuildOutput()
            .as(WebArchive.class);
    }

    @Test
    @RunAsClient
    public void shouldDoSth() throws Exception {
      ...
   }
}

为什么要使用 Maven Importer 而不是 war 部署? War 是在测试执行后创建的,这意味着如果 war 在测试执行期间存在,那么它来自以前的构建并且已过时。