Skip to content

Commit

Permalink
5dd905f suffered from a ClassLoader issue visible only in maven-junit…
Browse files Browse the repository at this point in the history
…-plugin (not Surefire).
  • Loading branch information
jglick committed Sep 5, 2012
1 parent 0805db1 commit 4557a43
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 10 deletions.
Expand Up @@ -58,6 +58,7 @@ public TestEnvironment(@Nonnull Description description) {

/**
* Current test case being run (works for JUnit 3 or 4).
* Warning: {@link Description#getTestClass} is currently broken in some environments. Use {@link Description#getClassName} instead.
*/
public @Nonnull Description description() {
if (description != null) {
Expand Down
19 changes: 9 additions & 10 deletions test/src/main/java/org/jvnet/hudson/test/TestExtensionLoader.java
Expand Up @@ -65,25 +65,24 @@ protected boolean isActive(AnnotatedElement e) {
Description description = env.description();
if (testName.length()>0 && !testName.equals(description.getMethodName()))
return false; // doesn't apply to this test

String className = description.getClassName();
if (e instanceof Class) {
return isActive(description, (Class)e);
for (Class<?> outer = (Class) e; outer != null; outer = outer.getEnclosingClass()) {
if (outer.getName().equals(className)) {
return true; // enclosed
}
}
return false;
}
if (e instanceof Field) {
Field f = (Field) e;
return f.getDeclaringClass() == description.getTestClass();
return f.getDeclaringClass().getName().equals(className);
}
if (e instanceof Method) {
Method m = (Method) e;
return m.getDeclaringClass() == description.getTestClass();
return m.getDeclaringClass().getName().equals(className);
}
return false;
}

private boolean isActive(Description description, Class<?> extType) {
for (Class<?> outer = extType; outer!=null; outer=outer.getEnclosingClass())
if (outer == description.getTestClass())
return true; // enclosed
return false;
}
}

1 comment on commit 4557a43

@kutzi
Copy link
Member

@kutzi kutzi commented on 4557a43 Jun 16, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

According to https://issues.jenkins-ci.org/browse/JENKINS-18262 this breaks @TestExtension loading in HudsonTestCase and JenkinsRule.
See also #814

Please sign in to comment.