从Eclipse运行时,Junit测试未找到系统属性 [英] Junit test not found system property when run from Eclipse

查看:219
本文介绍了从Eclipse运行时,Junit测试未找到系统属性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图使用Arquillian实现一个简单的CRUD应用程序并根据本教程进行测试: Java EE与Wildfly和Maven 。但是当我尝试从Eclipse运行测试时,它会抛出:
org.jboss.arquillian.container.spi.ConfigurationException:jbossHome'null'必须存在。
但是从命令行,使用mvn clean install,测试运行良好。

I tried to implement a simple CRUD application and tests with Arquillian based on this tutorial: Java EE with Wildfly and Maven. But when I try to run the tests from Eclipse it throws: org.jboss.arquillian.container.spi.ConfigurationException: jbossHome 'null' must exist. But from command line, use mvn clean install, the tests runs good.

我的pom.xml构建部分。

My pom.xml build part.

<build>
    <finalName>${project.artifactId}</finalName>
    <plugins>
        <plugin>
            <artifactId>maven-dependency-plugin</artifactId>
            <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.2.0.Final</version>
                                <type>zip</type>
                                <overWrite>false</overWrite>
                                <outputDirectory>target</outputDirectory>
                            </artifactItem>
                        </artifactItems>
                    </configuration>
                </execution>
            </executions>
        </plugin>

        <plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <version>2.17</version>
            <configuration>
                <configuration>
                    <reuseForks>false</reuseForks>
                    <forkCount>1</forkCount>
                </configuration>
                <systemPropertyVariables>
                    <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
                    <jboss.home>${project.basedir}/target/wildfly-8.2.0.Final</jboss.home>
                    <module.path>${project.basedir}/target/wildfly-8.2.0.Final/modules</module.path>
                </systemPropertyVariables>
                <redirectTestOutputToFile>false</redirectTestOutputToFile>
            </configuration>
        </plugin>
        <plugin>
            <artifactId>maven-war-plugin</artifactId>
            <version>${version.war.plugin}</version>
            <configuration>
                <failOnMissingWebXml>false</failOnMissingWebXml>
            </configuration>
        </plugin>
    </plugins>
</build>

如果我使用maven运行测试,jboss.home系统varibale由surefire插件设置,但是不明白为什么eclipse不能使用这个变量从pom.xml。

If I run tests with maven the jboss.home system varibale was set by the surefire plugin, but I can't understand why eclipse can't use this variables from pom.xml.

我正在寻找一个明确的解决方案来解决这个问题。 (如果可能,我想使用Eclipse从pom.xml中读取此配置,不要配置Eclipse运行设置。)

I looking for a clear solution for this problem. (If it's possible I want to use Eclipse to read this configuration from pom.xml not configure Eclipse run settings. )

对于语法错误,我使用我的英语知识很少。

Sorry for the grammatical errors, I use my english knowledge rarely.

推荐答案

我解决了这个问题,使用远程的wildfly容器进行开发和测试。它运行测试快速,在eclipse中,单击运行为Junit测试用例,所以我可以运行测试我想要的。

I solve this problem, using remote wildfly container under development, and testing. It runs tests fast, and in eclipse, click Run as Junit test case, so I can run the test what I want.

这篇关于从Eclipse运行时,Junit测试未找到系统属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆