Using one-jar with junit

2012-08-07
2013-05-23
  • Wayne Johnson
    Wayne Johnson
    2012-08-07

    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
    2012-08-08

    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.

    Simon.