[GRADLE-1682] Test classloader ordering seems to not be in parent first Created: 21/Jul/11 Updated: 13/Sep/16 Resolved: 13/Sep/16 |
|
Status: | Resolved |
Project: | Gradle |
Affects Version/s: | 1.0-milestone-3 |
Fix Version/s: | 3.2-rc-1 |
Type: | Bug | ||
Reporter: | Frédéric Camblor | Assignee: | Unassigned |
Resolution: | Fixed | Votes: | 12 |
Attachments: | gradle-runtimeTestClasspath-issue.tar |
Description |
When referencing the org.apache.felix:org.osgi.foundation artefact, which redefine rt.jar classes (Object class and so on...) in my unit tests, my tests are failing (with java.lang.IllegalArgumentException: superClassName is empty!) Looks like gradle is taking first the org.osgi.foundation jar, before rt.jar when executing tests. I attached a test project reproducing this problem. "superClassName is empty" error seems to appear when we have classes in src/test/java, that doesn't have any @Test annotation (that's why I provided the empty SomeNonTestClassThatWillBreakTheBuild class). |
Comments |
Comment by Shawn Ma [ 15/Sep/11 ] |
same issue here. from the debug log: 24872 21:21:02.807 [DEBUG] [org.gradle.api.internal.tasks.testing.detection.ClassFileExtractionManager] extracted class groovy/lang/Closure from groovy-all-1.7.10.jar |
Comment by Zach A. Thomas [ 24/Jun/12 ] |
I just ran into this. In my case, I don't have a direct dependency on org.osgi.foundation. I depend on org.osgi.compendium which pulls in foundation transitively. I'm brand new to gradle, interested in moving off of maven for a multi-module OSGi project[1]. If we can't run the tests, my investigation is more or less stalled. For a specific module where you can see this error, see [2] and use build.gradle at [3]. [1] https://github.com/sakaiproject/nakamura |
Comment by Andy Ma [ 30/Jan/13 ] |
I also have this issue, if no @Test annoation in a java file under src/test/java and also the project has dependency to "org.osgi.foundation" jar, this issue will happen, now I temporarily solve it by exclude dependency to "org.osgi.foundation" like follow in my gradle.build file.
configurations {
all*.exclude module: "org.osgi.foundation"
}
|
Comment by Olafur Egilsson [ 17/May/15 ] |
This almost four year old issue is still unresolved in Gradle 2.4. |
Comment by Sandu Turcan [ 16/Sep/15 ] |
I got the same error today. AbstractTestFrameworkDetector.java protected File getSuperTestClassFile(String superClassName) { prepareClasspath(); if (StringUtils.isEmpty(superClassName)) { throw new IllegalArgumentException("superClassName is empty!"); } final Iterator<File> testClassDirectoriesIt = testClassDirectories.iterator(); File superTestClassFile = null; while (superTestClassFile == null && testClassDirectoriesIt.hasNext()) { final File testClassDirectory = testClassDirectoriesIt.next(); final File superTestClassFileCandidate = new File(testClassDirectory, superClassName + ".class"); if (superTestClassFileCandidate.exists()) { superTestClassFile = superTestClassFileCandidate; } } if (superTestClassFile != null) { return superTestClassFile; } else { // super test class file not in test class directories // Skip JDK classes return superClassName.startsWith("java/") || superClassName.startsWith("javax/") ? null : classFileExtractionManager.getLibraryClassFile(superClassName); } } |
Comment by Piotr Jagielski [ 09/Feb/16 ] |
For future reference, there was an unfinished pull request that contain some discussion at https://github.com/gradle/gradle/pull/558. It would be great if someone from the community could pick it up. |
Comment by Jendrik Johannes (Inactive) [ 13/Sep/16 ] |
PR fixing this issue: https://github.com/gradle/gradle/pull/676 |