2012-09-02 16 views
6

के अंदर परीक्षण चलाता है मैं शुद्ध जुनीट 4 परीक्षण का उपयोग कर रहा हूं और मैंने उन्हें क्लासपाथ से संबंधित कुछ जारों के अंदर संकलित किया है। मैं अपने क्लासपाथ में सभी परीक्षणों को चलाने के लिए चाहता हूं।JUnit एक JAR

क्या कोई तरीका है?

मेरे कार्य लगता है:

<target name="test" description="All the tests"> 
    <junit fork="yes"> 
     <classpath> 
      <path refid="test.classpath" /> 
      <fileset dir="war/WEB-INF/lib/"> 
       <include name="*.jar"/> 
      </fileset> 
      <fileset dir="war/WEB-INF"/> 
      <fileset dir="war"/> 
     </classpath> 
    <formatter type="plain" usefile="false" /> 

    </junit> 
</target> 

उत्तर

5

उदाहरण नीचे मान लिया गया JUnit परीक्षण प्रत्यय "टेस्ट" इस तरह के "MyClassTest.java" के रूप में के साथ नाम हैं और JUnit 4 जार फ़ाइल एक पुस्तकालय निर्देशिका में है कि संपत्ति lib.dir द्वारा इंगित किया गया। संकलित परीक्षण वाले प्रत्येक जार फ़ाइल के लिए, ZipFileSet को नेस्टेड <batchtest> तत्व के भीतर परीक्षण कक्षाओं का चयन करने के लिए उपयोग किया जा सकता है। जुनीट 4 जार का मार्ग क्लासपाथ में शामिल किया गया है ताकि यह सुनिश्चित किया जा सके कि सही संस्करण का उपयोग किया जाता है।

<target name="test" description="All the tests."> 
    <junit fork="true"> 
    <classpath> 
     <fileset dir="war/WEB-INF/lib/" includes="**/*.jar" /> 
     <fileset dir="${lib.dir}" includes="junit*.jar" /> 
    </classpath> 
    <batchtest haltonfailure="true"> 
     <zipfileset src="war/WEB-INF/lib/test.jar" includes="**/*Test.class" /> 
    </batchtest> 
    <formatter type="plain" usefile="false" /> 
    </junit> 
</target> 
+0

यह बस काम कर रहा है, धन्यवाद –