1

My settings : TestNG 6.9.10 - Java 1.8 - Eclipse Mars.1 Release (4.5.1) Windows 10

Every time I run a TestNG test suite I have this error :

java.net.SocketException: Software caused connection abort: socket write error
    at java.net.SocketOutputStream.socketWrite0(Native Method)
    at java.net.SocketOutputStream.socketWrite(Unknown Source)
    at java.net.SocketOutputStream.write(Unknown Source)
    at java.io.ObjectOutputStream$BlockDataOutputStream.drain(Unknown Source)
    at java.io.ObjectOutputStream$BlockDataOutputStream.setBlockDataMode(Unknown Source)
    at java.io.ObjectOutputStream.<init>(Unknown Source)
    at org.testng.remote.strprotocol.SerializedMessageSender.sendMessage(SerializedMessageSender.java:24)
    at org.testng.remote.strprotocol.MessageHub.sendMessage(MessageHub.java:43)
    at org.testng.remote.RemoteTestNG$RemoteSuiteListener.onStart(RemoteTestNG.java:257)
    at org.testng.SuiteRunner.invokeListeners(SuiteRunner.java:208)
    at org.testng.SuiteRunner.run(SuiteRunner.java:266)
    at org.testng.SuiteRunnerWorker.runSuite(SuiteRunnerWorker.java:52)
    at org.testng.SuiteRunnerWorker.run(SuiteRunnerWorker.java:86)
    at org.testng.TestNG.runSuitesSequentially(TestNG.java:1244)
    at org.testng.TestNG.runSuitesLocally(TestNG.java:1169)
    at org.testng.TestNG.run(TestNG.java:1064)
    at org.testng.remote.RemoteTestNG.run(RemoteTestNG.java:113)
    at org.testng.remote.RemoteTestNG.initAndRun(RemoteTestNG.java:206)
    at org.testng.remote.RemoteTestNG.main(RemoteTestNG.java:177)

Even if my test class is empty :

import org.openqa.selenium.WebDriver;
import org.openqa.selenium.firefox.FirefoxDriver;
import org.testng.annotations.AfterTest;
import org.testng.annotations.BeforeTest;
import org.testng.annotations.Test;

public class sample {

    public WebDriver driver;


    @Test
    public void f() {
    }

    @BeforeTest
    public void beforeTest() {
        driver = new FirefoxDriver();
        driver.get("http://localhost:8081/login.html?profile=desktop");
    }

    @AfterTest
    public void afterTest() {
        driver.close();
    }

}

The test is running, so it doesn't interfere with the test case, but I really would like to understand and remove this Exception.

Thank you for any idea.

Neptune
  • 33
  • 2
  • 5
  • May be you can find answer in topic https://github.com/cbeust/testng-eclipse/issues/91 there are couple suggestions – dezhik Dec 15 '15 at 15:19

1 Answers1

-1

I'm thinking somewhere in WebDriver, java.net is used. Your localhost webserver is closing the socket or it was closed prematurely. Instead of using Before and After test, try to write it all in one Test method and debug. Unfortunately, there's no mention of your class in the stack trace to pinpoint which call is causing the problem.

Step through the following and see where the exception is thrown. If it's on the driver.get call, then your http server is likely rejecting the connections. If it's thrown at the close(), the connection has already been dropped (probably rejected by the server).

@Test
public void test() {
    driver = new FirefoxDriver();
    driver.get("http://localhost:8081/login.html?profile=desktop");
    driver.close();
}
borisveis
  • 911
  • 5
  • 2
  • I tried to debug every step like you suggested : I removed Before and After method, and copied the 3 lines in the method. But the exception is raised before the method is called, so I really don't know what happened. – Neptune Dec 17 '15 at 09:07