2011-01-21 6 views
5

के साथ सभी यूनिट परीक्षण चलाएं मेरे पास मेरी परियोजना में जुनीट परीक्षणों के समूह के साथ एक निर्देशिका है। अब तक मैंने प्रत्येक इकाई परीक्षण के लिए अलग-अलग लक्ष्य का उपयोग किया है। उदाहरण के लिए:चींटी बिल्डर

<target name="MyTest"> 
     <mkdir dir="${junit.output.dir}"/> 
     <junit fork="yes" printsummary="withOutAndErr"> 
      <formatter type="xml"/> 
      <test name="tests.MyTest" todir="${junit.output.dir}"/> 
      <classpath refid="MyProject.classpath"/> 
     </junit> 
    </target> 

इस विधि मुझे हर बार जब मैं एक इकाई परीक्षण जोड़ने का निर्माण फ़ाइल को बदलने के लिए की आवश्यकता है।
मैं एक एकल चींटी निर्माता लक्ष्य के साथ परियोजना में सभी यूनिट परीक्षण चलाने में सक्षम होना चाहता हूं।
क्या यह करना संभव है?

उत्तर

9

हां यह है, तो आप फ़ाइलसेट टैग को देखने के लिए, उदा की जरूरत है:

<junit printsummary="yes" haltonfailure="yes"> 
    <classpath> 
    <pathelement location="${build.tests}"/> 
    <pathelement path="${MyProject.classpath}"/> 
    </classpath> 

    <formatter type="xml"/> 

    <batchtest fork="yes" todir="${reports.tests}"> 
    <fileset dir="${src.tests}"> 
     <include name="**/*Test*.java"/> 
     <exclude name="**/AllTests.java"/> 
    </fileset> 
    </batchtest> 
</junit> 

महत्वपूर्ण हिस्सा परीक्षणों के नाम से मेल करने फ़ाइलसेट और एक ग्लोब/वाइल्डकार्ड पैटर्न का उपयोग है। यहाँ उदाहरण के साथ JUnit कार्य पर पूर्ण डॉक्स:

http://ant.apache.org/manual/Tasks/junit.html

3

हां! हम इसे चींटी कमांड बैचटेस्ट का उपयोग करते हैं। इस तरह दिखता है:

 <batchtest todir="${junit.report.dir}"> 
      <fileset dir="${basedir}\test\unit"> 
       <include name="**/*Test.java" /> 
      </fileset> 
     </batchtest> 

गूगल यह, यह आप को हल करना चाहिए