testng: Missing directory entries in testng jar

TestNG Version

6.13.1

Description:

  • Run jar -tf testng-6.13.1.jar
  • All entries for directories are not packaged in the jar. This causes a problem while trying to get resources from classpath.
  • In particular this causes problem in Arquillian integration with testng. See issue#comment

Expected behavior

META-INF/
META-INF/MANIFEST.MF
com/
com/beust/
com/beust/testng/
com/beust/testng/TestNG.class
org/

Actual behavior

com/beust/testng/TestNG.class
META-INF/services/org.testng.xml.ISuiteParser
org/testng/annotations/AfterClass.class

Test case sample

https://github.com/bartoszmajsak/testng-classloading

About this issue

  • Original URL
  • State: open
  • Created 6 years ago
  • Reactions: 1
  • Comments: 40 (27 by maintainers)

Most upvoted comments

@SomberOfShadow - The code snippet I shared will automatically ensure that the version of TestNG that is being resolved to is what will be used to obtain the path.

It is the entries for the directories that are missing for the JAR file, as listed in the “Expected behaviour”.

E.g., unzip -l testng-6.14.2.jar gives:

Archive:  testng-6.14.2.jar
  Length      Date    Time    Name
---------  ---------- -----   ----
     1332  02-05-2018 00:53   META-INF/MANIFEST.MF
      288  02-05-2018 00:53   com/beust/testng/TestNG.class
       30  02-05-2018 00:53   META-INF/services/org.testng.xml.ISuiteParser
      781  02-05-2018 00:53   org/testng/annotations/AfterClass.class
      800  02-05-2018 00:53   org/testng/annotations/AfterGroups.class
      815  02-05-2018 00:53   org/testng/annotations/AfterMethod.class
      781  02-05-2018 00:53   org/testng/annotations/AfterSuite.class
... etc.

but it should give something like this instead:

Archive: testng-6.14.2-with-directories.jar
  Length      Date    Time    Name
---------  ---------- -----   ----
        0  02-23-2018 12:13   META-INF/
     1332  02-05-2018 00:53   META-INF/MANIFEST.MF
        0  02-23-2018 12:13   META-INF/services/
       30  02-04-2018 05:53   META-INF/services/org.testng.xml.ISuiteParser
        0  02-23-2018 12:13   com/
        0  02-23-2018 12:13   com/beust/
        0  02-23-2018 12:13   com/beust/testng/
      288  02-04-2018 05:53   com/beust/testng/TestNG.class
        0  02-23-2018 12:13   org/
        0  02-23-2018 12:13   org/testng/
        0  02-23-2018 12:13   org/testng/annotations/
      781  02-04-2018 05:53   org/testng/annotations/AfterClass.class
      800  02-04-2018 05:53   org/testng/annotations/AfterGroups.class
... etc.

I confirm that this causes a problem with Arquillian. If you merely unzip the testng-6.14.2.jar file to extract its contents, then use zip to create a new JAR file with the same contents, that JAR file does contain the directory entries, and it does then work with Arquillian.