From bee707ec10175c086f859940b8af5b83efd22b02 Mon Sep 17 00:00:00 2001 From: Marc Khouzam Date: Thu, 17 May 2012 14:59:56 -0400 Subject: [PATCH] Bug 379841: [tests] Add a timeout for each JUnit test Change-Id: Icb33e03f91404650457a103246d3276e157c64d4 Reviewed-on: https://git.eclipse.org/r/6017 Reviewed-by: Marc Khouzam IP-Clean: Marc Khouzam Tested-by: Marc Khouzam --- .../eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java index 94c5d2decea..fc56430565b 100644 --- a/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java +++ b/dsf-gdb/org.eclipse.cdt.tests.dsf.gdb/src/org/eclipse/cdt/tests/dsf/gdb/framework/BaseTestCase.java @@ -42,6 +42,8 @@ import org.junit.Assert; import org.junit.Before; import org.junit.Rule; import org.junit.rules.TestName; +import org.junit.rules.TestRule; +import org.junit.rules.Timeout; /** * This is the base class for the GDB/MI Unit tests. @@ -52,10 +54,15 @@ import org.junit.rules.TestName; * code is to be run. */ public class BaseTestCase { + // Timeout value for each individual test + private final static int TEST_TIMEOUT = 5 * 60 * 1000; // 5 minutes in milliseconds // Make the current test naem available through testName.getMethodName() @Rule public TestName testName = new TestName(); + // Add a timeout for each test, to make sure no test hangs + @Rule public TestRule timeout = new Timeout(TEST_TIMEOUT); + public static final String ATTR_DEBUG_SERVER_NAME = TestsPlugin.PLUGIN_ID + ".DEBUG_SERVER_NAME"; private static final String DEFAULT_TEST_APP = "data/launch/bin/GDBMIGenericTestApp.exe";