IC-213.3714.440 testFramework.jar lacks package directory entries

已回答

lib/testFramework.jar lacks package directory entries in the build IC-213.3714.440. This can be seen for example by executing `jar tvf lib/testFramework.jar`. The jar content listing of the release version (tried with 2021.2) results in package directories in stdout while there are just .class files in case of IC-213.3714.440.

This makes it impossible to use testFramework.jar by Gradle :test task if a test case refers to a superclass in testFramework.jar. Gradle takes advantage of directory entries (see https://github.com/gradle/gradle/blob/master/subprojects/testing-jvm/src/main/java/org/gradle/api/internal/tasks/testing/detection/JarFilePackageLister.java) when it builds a mapping from package names to library files. As a result, the error below will appear and the corresponding test cases will not be resolved.

[DEBUG] [org.gradle.api.internal.tasks.testing.detection.AbstractTestFrameworkDetector] test-class-scan : failed to scan parent class com/intellij/testFramework/HeavyPlatformTestCase, could not find the class file

评论操作 固定链接

Related Gradle's issue: https://github.com/gradle/gradle/issues/18486

A possible workaround: add

@RunWith(JUnit38ClassRunner::class)

annotation for all your base classes for testing.

2
评论操作 固定链接

Could you clarify please what do you mean by "lacks of package directory entries" exactly? I see the testFramework.jar file has the same structure in 2021.2 and 2021.3 versions.

0
评论操作 固定链接

jar tf ideaIC-2021.2/lib/testFramework.jar results in a list starting with

META-INF/

META-INF/MANIFEST.MF

com/

com/intellij/

com/intellij/codeInsight/

com/intellij/codeInsight/daemon/

com/intellij/codeInsight/daemon/quickFix/

com/intellij/codeInsight/folding/

com/intellij/codeInsight/folding/impl/

com/intellij/codeInsight/unwrap/

 

jar tf ideaIC-LATEST-EAP-SNAPSHOT/lib/testFramework.jar results in a list starting with

_FirstInSuiteTest.class

_LastInSuiteTest.class

META-INF/intellij.platform.testFramework.kotlin_module

mockito-extensions/org.mockito.plugins.MockMaker

com/intellij/FileSetTestCase$ActualTest.class

com/intellij/FileSetTestCase.class

com/intellij/InternalTestDiscoveryListener.class

 

For example, if we take FileSetTestCase.class then in case of 2021.2 version there are entries com/intellij and com/intellij/FileSetTestCase.class, but in the 2021.3 EAP snapshot there only com/intellij/FileSetTestCase.class.

Another way to check the difference is listing all non-class files: jar tf lib/testFramework.jar | grep -v class 

Sure, the structure is the same if the jar file is unpacked. The problem is that Gradle processes the jar file directly by iterating over ZipFileEntries and checking specifically directory entries. 

0
评论操作 固定链接

Thank you for details. I've asked the developer to comment.

0
评论操作 固定链接

Created the IDEA-279572 IC-213.3714.440 testFramework.jar lacks package directory entries

issue about this problem. Please vote and subscribe to updates from the developer on it in the YouTrack. Thank you.

0

请先登录再写评论。