Using one-jar with junit

  • Wayne Johnson
    Wayne Johnson

    I'm trying to set up one-jar to create some stand-alone unit tests.  This means that the jar would contain the test classes and some additional test code, but the bulk of the code under test will be already installed in the local directory.

    How can I set it up for this split environment. that is having a classpath both in and outside of the one-jar jar. 

    Anyone have any ideas?

  • P. Simon Tuffs
    P. Simon Tuffs

    You should be able to use the Class-Path manifest attribute in the one-jar to gain access to external classes. You will need to specify either relative or full paths to the .jar files which comprise the classpath (or the directories that contain classes).  This needs to be hard-wired into the one-jar since it is read when the JVM loads the jar, which means you can't parameterize or discover the location of the classes and jars that you want to test.  Let me know how this works out.