Configuring ant to run unit tests. Where should libraries be? How should classpath be configured? avoiding ZipException

后端 未结 5 1760
花落未央
花落未央 2021-02-05 08:18

I\'m trying to run my junit tests using ant. The tests are kicked off using a JUnit 4 test suite. If I run this direct from Eclipse the tests complete without error. However i

5条回答
  •  [愿得一人]
    2021-02-05 08:24

    This error is caused specifically because the class path contains explicit references to one or more [files] that are not JAR's. The reference to "error in opening zip file" is of course that a JAR is in effect a ZIP file where as other files [JUNIT] has found like class files are not and as such do not have a zip format. So the class path should contain only explicit references to JAR [files] and/or the names of the [directories] where other resources like class files are to be found.

    So when building up your class path (in ANT) use:

    
               :one for each of the [directories] where class files, log4j property files and other resources etc are to be found
                           :to describe all the explicit JAR [files] that need to be on the class path.
    
    

    where

    
        
        
        
    
    

    or

    NOTE: When using wild cards like [**/*] in you need to make sure the wild card is not matching files that are not JAR files

    
        
    
    

提交回复
热议问题