[testng-dev] TimeOuts not working when launching TestNG from code

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
Report Content as Inappropriate

[testng-dev] TimeOuts not working when launching TestNG from code

Andres Antonen
I am trying to run a test using an instance of TestNG class. The code looks something like this:

import org.testng.TestNG;
import org.testng.annotations.Test;

public class TestNGHangTest {
private class ExampleTest {
private void iWorkWell() {
@Test(timeOut = 100, dependsOnMethods= {"iWorkWell"})
private void iHangHorribly() {
while (true) {
int two = 1 + 1;
@Test(dependsOnMethods= {"iHangHorribly"})
private void iAmNeverRun() {
public static void main(String[] args) {
TestNG testng = new TestNG();
.setTestClasses(new Class[] { ExampleTest.class });

The infinite loop should be killed and the third test skipped, but the thread running the loop never ends. When the same inner class is tested using Eclipse's TestNG plugin, it works as expected.
Since the code does not exit properly, it does not generate a report and wastes CPU cycles, forcing me to terminate JVM manually.

You received this message because you are subscribed to the Google Groups "testng-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at https://groups.google.com/group/testng-dev.
For more options, visit https://groups.google.com/d/optout.