From 82359624ea05915b88d33084eadae5fa1c041160 Mon Sep 17 00:00:00 2001 From: Vincent Latombe Date: Thu, 23 Jan 2025 17:41:38 +0100 Subject: [PATCH] Fixes `@LocalData` when being used on a test method in superclass (#907) --- .../java/org/jvnet/hudson/test/recipes/LocalData.java | 2 +- .../jvnet/hudson/test/recipes/LocalDataExtendedTest.java | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) create mode 100644 src/test/java/org/jvnet/hudson/test/recipes/LocalDataExtendedTest.java diff --git a/src/main/java/org/jvnet/hudson/test/recipes/LocalData.java b/src/main/java/org/jvnet/hudson/test/recipes/LocalData.java index 28e8a5218..aa1b4e1ec 100644 --- a/src/main/java/org/jvnet/hudson/test/recipes/LocalData.java +++ b/src/main/java/org/jvnet/hudson/test/recipes/LocalData.java @@ -102,7 +102,7 @@ public void setup(JenkinsRule jenkinsRule, LocalData recipe) throws Exception { Method testMethod; try { - testMethod = desc.getTestClass().getDeclaredMethod(desc.getMethodName()); + testMethod = desc.getTestClass().getMethod(desc.getMethodName()); } catch (NoSuchMethodException ex) { testMethod = desc.getTestClass().getDeclaredMethod(desc.getMethodName(), JenkinsRule.class); } diff --git a/src/test/java/org/jvnet/hudson/test/recipes/LocalDataExtendedTest.java b/src/test/java/org/jvnet/hudson/test/recipes/LocalDataExtendedTest.java new file mode 100644 index 000000000..109704d4f --- /dev/null +++ b/src/test/java/org/jvnet/hudson/test/recipes/LocalDataExtendedTest.java @@ -0,0 +1,8 @@ +package org.jvnet.hudson.test.recipes; + + +/** + * Illustrates a case where a test class extends another test class that has test methods using the LocalData recipe. + */ +public class LocalDataExtendedTest extends LocalDataZipTest { +}