尝试运行测试时“无法联系RemoteTestNG客户端”错误

时间:2012-11-18 12:32:05

标签: eclipse maven testng

问题

在maven托管项目上使用TestNG,我似乎无法通过TestNG eclipse插件运行测试。尝试运行测试时,会弹出以下错误消息(在对话框窗口内):

  

无法联系RemoteTestNG客户端。确保你没有   类路径上的旧版testng.jar。

     

原因:
  尝试联系RemoteTestNG时超时。

如何解决这个问题?

我尝试过的事情

(在办公室QA部门询问所有我的同事之后,通过常见搜索引擎和TestNG论坛查询信息)

  • 确保我的课程路径上没有旧版本(当然)。
  • 消除了TestNG eclipse插件使用的maven导入的jar和jar之间可能发生的冲突(两者都是版本6.7,项目的pom.xml确认只使用自己的依赖jar)。
  • 在所述更改后执行maven更新和构建。
  • 在不同的JRE(特别是1.7.0)上运行。

相关信息

环境:

  • 操作系统:Win XP pro SP3
  • JRE: 1.6.0 update 31
  • TestNG: 6.7
  • Maven: 3.0.3
  • IDE: Eclipse Juno Java EE SR1

pom.xml内容:

<?xml version="1.0" encoding="UTF-8" ?>
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
    <modelVersion>4.0.0</modelVersion>
    <artifactId>SGTest</artifactId>
    <name>SGTest</name>
    <description>Service Grid Test project for XAP</description>

    <parent>
        <groupId>com.my_product.quality.sgtest</groupId>
        <artifactId>SGTest-parent</artifactId>
        <version>3.0.0</version>
        <relativePath>http://mvn-srv:8081/artifactory/libs-snapshot-local/com/my_product/quality/sgtest/SGTest-parent/3.0.0/SGTest-parent-3.0.0.pom</relativePath>
    </parent>

    <properties>
        <xap.home>${env.XAP_LATEST}</xap.home>
    </properties>

    <dependencies>
        <dependency>
            <groupId>com.my_product</groupId>
            <artifactId>my_opensource_product</artifactId>
            <version>${gsVersion}</version>
            <scope>system</scope>
            <systemPath>${xap.home}/lib/required/my_opensource_product.jar</systemPath>
        </dependency>
        <dependency>
            <groupId>com.my_product</groupId>
            <artifactId>gs-runtime</artifactId>
            <version>${gsVersion}</version>
            <scope>system</scope>
            <systemPath>${xap.home}/lib/required/gs-runtime.jar</systemPath>
        </dependency>
        <dependency>
            <groupId>com.my_product.quality</groupId>
            <artifactId>DashboardReporter</artifactId>
            <version>0.0.1</version>
        </dependency>
        <dependency>
            <groupId>${project.groupId}</groupId>
            <artifactId>apps</artifactId>
            <version>${project.version}</version>
            <type>pom</type>
        </dependency>
        <dependency>
            <groupId>com.my_product.quality</groupId>
            <artifactId>webuitf</artifactId>
            <version>1.0.0</version>
        </dependency>
        <dependency>
            <groupId>com.my_product.quality</groupId>
            <artifactId>wanem</artifactId>
            <version>0.0.1-SNAPSHOT</version>
        </dependency>
        <dependency>
            <groupId>org.my_opensource_product.xenserver</groupId>
            <artifactId>xenserver-machine-provisioning</artifactId>
            <version>2.0.0</version>
        </dependency>
        <dependency>
            <groupId>org.swift.common</groupId>
            <artifactId>confluence-soap</artifactId>
            <version>0.5</version>
        </dependency>
        <dependency>
            <groupId>org.testng</groupId>
            <artifactId>testng</artifactId>
            <version>6.7</version>
        </dependency>
        <dependency>
            <groupId>org.apache.ant</groupId>
            <artifactId>ant-jsch</artifactId>
            <version>1.8.3</version>
        </dependency>
        <dependency>
            <groupId>org.hibernate</groupId>
            <artifactId>hibernate-entitymanager</artifactId>
        </dependency>
        <dependency>
            <groupId>com.thoughtworks.xstream</groupId>
            <artifactId>xstream</artifactId>
            <version>1.4.2</version>
        </dependency>
        <dependency>
            <groupId>javax.mail</groupId>
            <artifactId>mail</artifactId>
            <version>1.4.5</version>
        </dependency>
        <dependency>
            <groupId>org.codehaus.groovy</groupId>
            <artifactId>groovy-all</artifactId>
            <version>1.8.6</version>
        </dependency>
        <dependency>
            <groupId>org.apache.commons</groupId>
            <artifactId>commons-vfs2</artifactId>
            <version>2.0</version>
        </dependency>
        <dependency>
            <groupId>org.hyperic</groupId>
            <artifactId>sigar</artifactId>
            <version>1.6.5</version>
            <scope>system</scope>
            <systemPath>${xap.home}/lib/platform/sigar/sigar.jar</systemPath>
        </dependency>
        <dependency>
            <groupId>org.springframework</groupId>
            <artifactId>spring-jms</artifactId>
            <version>3.1.1.RELEASE</version>
        </dependency>
        <dependency>
            <groupId>hsqldb</groupId>
            <artifactId>hsqldb</artifactId>
            <version>1.8.0.10</version>
        </dependency>
        <dependency>
            <groupId>org.hamcrest</groupId>
            <artifactId>hamcrest-all</artifactId>
            <version>1.3</version>
        </dependency>
    </dependencies>

    <build>
        <testSourceDirectory>src/main/java</testSourceDirectory>
        <plugins>
            <plugin>
                <groupId>org.apache.maven.plugins</groupId>
                <artifactId>maven-surefire-plugin</artifactId>
                <version>2.12.4</version>
                <configuration>
                    <classpathDependencyExcludes>
                        <classpathDependencyExcludes>com.my_product.quality.sgtest.apps.security:processor</classpathDependencyExcludes>
                        <classpathDependencyExcludes>com.my_product.quality.sgtest.apps.archives:customSecurityProcessor</classpathDependencyExcludes>
                        <classpathDependencyScopeExclude>runtime</classpathDependencyScopeExclude>
                    </classpathDependencyExcludes>
                    <argLine>-Xmx2048m -XX:MaxPermSize=512m</argLine>
                    <includes>
                        <include>${includes}</include>
                    </includes>
                    <excludes>
                        <exclude>${excludes}</exclude>
                    </excludes>
                    <disableXmlReport>true</disableXmlReport>
                    <reportsDirectory>${sgtest.summary.dir}</reportsDirectory>
                    <reportFormat>xml</reportFormat>
                    <properties>
                        <property>
                            <name>configfailurepolicy</name>
                            <value>continue</value>
                        </property>
                        <property>
                            <name>suitename</name>
                            <value>${sgtest.suiteName}${sgtest.suiteId}</value>
                        </property>
                        <property>
                            <name>testname</name>
                            <value>${sgtest.suiteName}${sgtest.suiteId}</value>
                        </property>
                        <property>
                            <name>outputDir</name>
                            <value>${sgtest.summary.dir}</value>
                        </property>
                        <property>
                            <name>listener</name>
                            <value>framework.testng.SGTestNGListener,framework.testng.SGTestNgSuiteSplitter,framework.testng.report.TestNgReporterImpl</value>
                        </property>
                    </properties>
                    <systemProperties>
                        <sgtest.suiteId>${sgtest.suiteId}</sgtest.suiteId>
                        <sgtest.numOfSuites>${sgtest.numOfSuites}</sgtest.numOfSuites>
                        <selenium.browser>${selenium.browser}</selenium.browser>
                        <org.apache.commons.logging.Log>org.apache.commons.logging.impl.Jdk14Logger</org.apache.commons.logging.Log>
                        <com.gs.logging.level.config>true</com.gs.logging.level.config>
                        <java.util.logging.config.file>${basedir}/logging/sgtest_logging.properties</java.util.logging.config.file>
                        <sgtest.buildFolder>${sgtest.buildFolder}</sgtest.buildFolder>
                        <sgtest.url>http://192.168.9.121:8087/sgtest3.0-xap/</sgtest.url>
                        <sgtest.disconnect.machines>${sgtest.disconnect.machines}</sgtest.disconnect.machines>
                        <com.gs.work>${com.gs.work}</com.gs.work>
                        <com.gs.deploy>${com.gs.deploy}"</com.gs.deploy>
                        <cppOS>${cppOS}</cppOS>
                    </systemProperties>
                    <testFailureIgnore>true</testFailureIgnore>
                    <detail>true</detail>
                </configuration>
            </plugin>
            <plugin>
                <artifactId>maven-assembly-plugin</artifactId>
                <version>2.3</version>
                <configuration>
                    <descriptors>
                        <descriptor>src/main/assembly/assembly.xml</descriptor>
                    </descriptors>
                    <appendAssemblyId>false</appendAssemblyId>
                </configuration>
                <executions>
                    <execution>
                        <id>make-assembly</id> <!-- this is used for inheritance merges -->
                        <phase>package</phase> <!-- bind to the packaging phase -->
                        <goals>
                            <goal>single</goal>
                        </goals>
                    </execution>
                </executions>
            </plugin>
        </plugins>
    </build>
</project>

4 个答案:

答案 0 :(得分:2)

我能够通过错误地配置我的TestNG启动配置(在eclipse中)来解决确切的问题。 具体来说,我指定它将以下内容作为JVM参数传递:

-runTestAsTool=true

而不是

-DrunTestAsTool=true

添加缺失的D为我修复了它。 因此,可以仔细检查您的启动配置的配置方式。

答案 1 :(得分:1)

此问题源自在Windows上运行长Java类路径时出现的问题(这些问题超出了进程创建命令限制)。 Eclipse错误跟踪系统已经reported,并且还讨论了here on Stackoverflow

要在Eclipse Juno版本上解决此问题,我们可以绕过命令限制(使用上面linked post中建议的解决方案),或者从报告的错误中应用补丁。

Ivan Sim发布了修补说明on his coderwall,但为了完整起见,我会附上一段摘录:

  
      
  1. 从上面的link
  2. 下载bug3271933.4.2hack.zip   
  3. 备份现有的eclipse / plugins / org.eclipse.jdt.launching_3.4。*。jar
  4.   
  5. 将补丁中的类复制并粘贴到org.eclipse.jdt.launching中的org / eclipse / jdt / internal / launch中   JAR(替换现有文件)
  6.   
  7. 编辑org.eclipse.jdt.launching JAR文件中的META-INF /MANIFEST.MF文件,删除所有内容   来自第一个&#34; NAME:&#34;条目。确保你留下两(2)次换行   文件末尾的字符。
  8.   
  9. 重新启动eclipse
  10.   

答案 2 :(得分:0)

似乎TestNG尝试通过创建socket到'localhost'连接到JVM实例,在我的/ etc / hosts(我使用linux)文件中我将localhost重命名为其他东西,因此它被轰炸了。

更改回localhost,一切都很好。

答案 3 :(得分:0)

请确保Mac OS或Windows上的Socks5代理已关闭。

相关问题