'gradle test' hangs in case of unexpected error inside SocketConnection.dispatch(SocketConnection.java:112)


(Anton Gnutov) #1

Test class:

package org.gradle.test;
  import org.testng.annotations.Test;
  public class Test1 {
    @Test
    public void test() {
    }
}

Listener class:

package org.gradle.test;
  import org.testng.*;
  public class Listener1 implements IInvokedMethodListener {
      public void beforeInvocation(IInvokedMethod iInvokedMethod, ITestResult iTestResult) {
    }
      public void afterInvocation(IInvokedMethod method, ITestResult iTestResult) {
        iTestResult.setStatus(ITestResult.FAILURE);
            // if uncomment - it works
        // iTestResult.setThrowable(new RuntimeException());
    }
}

build script:

apply plugin: 'java'
  repositories {
    mavenCentral()
}
  dependencies {
    compile "org.testng:testng:6.8.7"
}
  test {
   useTestNG() {
       listeners << 'org.gradle.test.Listener1'
       suiteXmlFiles = ["src/test/resources/testng.xml" as File]
   }
}