From d87c272207b17c4f225ceae74f67574f56de59a6 Mon Sep 17 00:00:00 2001 From: Simeon Andreev Date: Tue, 3 Sep 2019 09:11:25 +0200 Subject: Bug 548456 - Ensure core model tests fail if test case misses suite() org.eclipse.jdt.core.tests.model.AllJavaModelTests will visit each of the included test cases and call its suite() method over reflection to instantiate the test case. If the suite() method is not found, an exception stack trace is printed instead of throwing an exception. So forgetting the suite() method in a new test case does not result in a failure. This can easily hide the fact that the new test case is not running at all. This change re-throws the exception instead of only printing its stack trace, so that missing suite() method in an included test case results in a failure. Change-Id: I2e8cc25cca943961caf815cd9bc04eaf781facd4 Signed-off-by: Simeon Andreev --- .../src/org/eclipse/jdt/core/tests/model/AllJavaModelTests.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AllJavaModelTests.java b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AllJavaModelTests.java index 487061a824..1fa9b48651 100644 --- a/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AllJavaModelTests.java +++ b/org.eclipse.jdt.core.tests.model/src/org/eclipse/jdt/core/tests/model/AllJavaModelTests.java @@ -268,17 +268,17 @@ public static Test suite() { suiteMethod = clazz.getDeclaredMethod("suite", new Class[0]); } catch (NoSuchMethodException e) { e.printStackTrace(); - continue; + throw new AssertionError("Failed to find suite() method for: " + clazz, e); } Object test; try { test = suiteMethod.invoke(null, new Object[0]); } catch (IllegalAccessException e) { e.printStackTrace(); - continue; + throw new AssertionError("Failed to invoke suite() method for: " + clazz, e); } catch (InvocationTargetException e) { e.printStackTrace(); - continue; + throw new AssertionError("Failed to invoke suite() method for: " + clazz, e); } suite.addTest((Test) test); } -- cgit v1.2.3