TestNG error when executing script in eclipse ide

2019-08-22 10:02发布

问题:

This is the error when I am trying to execute script in selenium ide using testNG

[RemoteTestNG] detected TestNG version 6.12.0
java.lang.NoSuchMethodError: org.testng.remote.support.RemoteTestNG6_12.initializeEverything()V
    at org.testng.remote.support.RemoteTestNG6_12.initialize(RemoteTestNG6_12.java:22)
    at org.testng.remote.AbstractRemoteTestNG.run(AbstractRemoteTestNG.java:97)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:251)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:77)

回答1:

it looks really weird that detected version 6.12 but running with the other version. AFAIK, selenium has an embedded TestNG which definitely older than 6.12. from the screenshot, could you adjust the library order, to move "TestNG" upper of "Referenced Libraries": right click on the project -> Build Path -> Configure Build Path... -> on tab "Order and Export", select "TestNG", then click the "Up" button to move it up. also, could you share the sample project here: https://github.com/cbeust/testng-eclipse/issues/355, so that probably can conduct a right fix at TestNG Eclipse Plugin


Edit: It's a classpath issue, you need to remove the redundant and old testng-6.0.jar

<?xml version="1.0" encoding="UTF-8"?>
<classpath>
    <classpathentry kind="src" path="src"/>
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8"/>
    <classpathentry kind="lib" path="D:/Softwares/selenium-java-3.4.0/lib/cglib-nodep-3.2.4.jar"/>
...
    <classpathentry kind="lib" path="D:/Softwares/selenium-java-3.4.0/client-combined-3.4.0-nodeps.jar"/>
<!-- Nick: you need to remove this entry: testng-6.0.jar, it's recommended to use TESTNG_CONTAINER  -->
    <classpathentry kind="lib" path="C:/Users/orange/Downloads/testng-6.0.jar"/>
    <classpathentry kind="con" path="org.testng.TESTNG_CONTAINER"/>
    <classpathentry kind="output" path="bin"/>
</classpath>