没有为解决方案设置依赖项

时间:2018-03-02 15:45:29

标签: java jboss-arquillian shrinkwrap

我使用Arquillian集成测试框架运行测试。 “Arquillian不使用整个类路径来隔离测试档案。而是使用ShrinkWrap类,即用于创建档案的Java API。当我们创建要测试的档案时,我们指定要包含在类路径中的文件以供使用在部署期间,ShrinkWrap仅隔离测试所需的类“(Introduction to Testing with Arquillian)。

有我的配置:

@Deployment
public static WebArchive createDeployment() {
    MavenResolverSystem resolver = Maven.resolver();
    File[] files = resolver.loadPomFromFile("pom.xml").importRuntimeAndTestDependencies().resolve().withTransitivity().asFile();

    WebArchive webArchive = ShrinkWrap.create(WebArchive.class, "test.war");
    webArchive.addAsLibraries(files)
            .addClasses("There I add my classess")
    .addAsManifestResource("arquillian/arquillian.xml");

    System.out.println(webArchive.toString(true));
    return webArchive;
}

和pom.xml:

<dependency>
        <groupId>org.jboss.arquillian</groupId>
        <artifactId>arquillian-bom</artifactId>
        <type>pom</type>
    </dependency>
    <dependency>
        <groupId>org.jboss.arquillian.container</groupId>
        <artifactId>arquillian-tomcat-embedded-8</artifactId>
    </dependency>
    <dependency>
        <groupId>org.jboss.arquillian.junit</groupId>
        <artifactId>arquillian-junit-container</artifactId>
        <scope>test</scope>
    </dependency>
    <dependency>
        <groupId>org.jboss.arquillian.container</groupId>
        <artifactId>arquillian-container-spi</artifactId>
    </dependency>
    <dependency>
        <groupId>org.jboss.arquillian.container</groupId>
        <artifactId>arquillian-container-test-spi</artifactId>
    </dependency>
    <dependency>
        <groupId>org.apache.tomcat</groupId>
        <artifactId>tomcat-catalina</artifactId>
    </dependency>
    <dependency>
        <groupId>org.glassfish.main.extras</groupId>
        <artifactId>glassfish-embedded-all</artifactId>
    </dependency>
    <dependency>
        <groupId>org.jboss.shrinkwrap.resolver</groupId>
        <artifactId>shrinkwrap-resolver-impl-maven</artifactId>
        <scope>test</scope>
    </dependency>

但是我在使用stacktrace时遇到错误:

java.lang.RuntimeException: Could not invoke deployment method: public static org.jboss.shrinkwrap.api.spec.WebArchive com.project.MyControllerTest.createDeployment()
Caused by: java.lang.IllegalArgumentException: No dependencies were set for resolution
INFO: Stopping service [arquillian-tomcat-embedded]

我错过了什么?

0 个答案:

没有答案
相关问题