Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/317.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 在IntelliJ中调试Arquillian测试_Java_Unit Testing_Junit_Jboss7.x_Jboss Arquillian - Fatal编程技术网

Java 在IntelliJ中调试Arquillian测试

Java 在IntelliJ中调试Arquillian测试,java,unit-testing,junit,jboss7.x,jboss-arquillian,Java,Unit Testing,Junit,Jboss7.x,Jboss Arquillian,我有一个JavaEE项目,在该项目中,我在JBoss7(Windows)上使用JUnit进行Arquillian测试。测试工作正常,但我无法调试它们 从Google()中我了解到Arquillian测试是在单独的VM中运行的,因此IntelliJ无法调试它们。我需要IntelliJ通过插座远程连接到那台机器,但我不知道怎么做 我发现了这个线索:但是我不知道如何让它工作 我也跳过了这个主题:所以我在pom.xml中填写了希望合适的surefire部分,但它没有帮助: <plugin>

我有一个JavaEE项目,在该项目中,我在JBoss7(Windows)上使用JUnit进行Arquillian测试。测试工作正常,但我无法调试它们

从Google()中我了解到Arquillian测试是在单独的VM中运行的,因此IntelliJ无法调试它们。我需要IntelliJ通过插座远程连接到那台机器,但我不知道怎么做

我发现了这个线索:但是我不知道如何让它工作

我也跳过了这个主题:所以我在pom.xml中填写了希望合适的surefire部分,但它没有帮助:

<plugin>
    <artifactId>maven-surefire-plugin</artifactId>
        <version>2.4.3</version>
        <configuration>
            <debugForkedProcess>true</debugForkedProcess>
        <skip>false</skip>
    </configuration>
 </plugin>

maven surefire插件
2.4.3
真的
假的

有人能告诉我如何在这种配置中调试测试吗?

首先取决于您使用的容器类型-托管、远程或嵌入式。另见。对于后者,测试在同一JVM中运行,例如,您可以直接在IDE中调试测试

在这种情况下,Surefire配置并不重要,因为您希望在IDE中进行调试(除非您是从IDE中执行maven目标)

对于托管容器和远程容器,您需要调试实际容器。为此,您必须将正确的JVM选项传递给远程容器,以便打开远程调试会话。一种方法是通过arquillian.xml:

http://jboss.org/schema/arquillian/arquillian_1_0.xsd“>


目标/工件
${jbossTargetDir}
-Xmx1024m-XX:MaxPermSize=512m-Xnoagent-Djava.compiler=NONE-Xdebug-Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=5005
真的


上面示例中的重要部分是javaVmArguments。

我可以通过Maven或IntelliJ运行Arqullian测试。我使用嵌入式容器。最重要的是在Arqullian.xml中配置JBoss home,也不只是在Maven配置中配置,以便IntelliJ知道JBoss home在哪里

<arquillian xmlns="http://jboss.org/schema/arquillian"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://jboss.org/schema/arquillian
    http://jboss.org/schema/arquillian/arquillian_1_0.xsd">

<engine>
    <property name="deploymentExportPath">testing/target/artifacts</property>
</engine>

<container qualifier="jbossas-managed" default="true">
    <configuration>

        <!-- JBoss embedded does not use this property
        <property name="javaVmArguments">-java.util.logging.manager=org.jboss.logmanager.LogManager -Xmx512m -XX:MaxPermSize=256m -Djava.util.logging.manager=org.jboss.logmanager.LogManager</property>
        -->

        <property name="jbossHome">target/wildfly-8.1.0.Final</property>
        <property name="modulePath">target/wildfly-8.1.0.Final/modules</property>
        <property name="allowConnectingToRunningServer">true</property>
    </configuration>
</container>


通过远程调试总是有可能的。我喜欢在IDE上进行调试。对我来说,这是一种更方便的方式。当你想启用远程调试时,你必须将配置设置为JAVA_OPT For embedded container,也不能设置为arqullian.xml。

我使用托管容器。我尝试了你的建议,但当开始调试时,我看到了控制台:
正在侦听地址为5005的transport dt_套接字,但没有发生更多的事情。我发现这是因为
suspend=y
参数。我想现在我应该让IntelliJ连接到调试会话,但我不知道怎么做。最后我可以调试我的测试。我使用
mvn测试-Parq jbossas managed
来运行JBossVM,然后我使用IntelliJ中的远程配置文件连接到该VM。是否可以在IntelliJ中自动进行连接?我的意思是在连接之前运行
mvn测试
?我也想知道如何调试Arquillian测试,就像Idea中的简单单元测试一样
<arquillian xmlns="http://jboss.org/schema/arquillian"
        xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
        xsi:schemaLocation="http://jboss.org/schema/arquillian
    http://jboss.org/schema/arquillian/arquillian_1_0.xsd">

<engine>
    <property name="deploymentExportPath">testing/target/artifacts</property>
</engine>

<container qualifier="jbossas-managed" default="true">
    <configuration>

        <!-- JBoss embedded does not use this property
        <property name="javaVmArguments">-java.util.logging.manager=org.jboss.logmanager.LogManager -Xmx512m -XX:MaxPermSize=256m -Djava.util.logging.manager=org.jboss.logmanager.LogManager</property>
        -->

        <property name="jbossHome">target/wildfly-8.1.0.Final</property>
        <property name="modulePath">target/wildfly-8.1.0.Final/modules</property>
        <property name="allowConnectingToRunningServer">true</property>
    </configuration>
</container>
<plugin>
            <groupId>org.apache.maven.plugins</groupId>
            <artifactId>maven-surefire-plugin</artifactId>
            <configuration>
                <!-- Fork every test because it will launch a separate AS instance -->
                <forkMode>always</forkMode>
                <systemPropertyVariables>
                    <java.util.logging.manager>org.jboss.logmanager.LogManager</java.util.logging.manager>
                </systemPropertyVariables>
                <redirectTestOutputToFile>false</redirectTestOutputToFile>
            </configuration>
        </plugin>