2011-09-26 9 views
8

के साथ यूनिट परीक्षण धीमा है मैंने हाल ही में अपनी चींटी बिल्ड स्क्रिप्ट में कोबर्टुरा को एकीकृत किया है और मुझे आश्चर्य है कि मैंने इसे सही तरीके से किया है क्योंकि यह यूनिट परीक्षण चलाने में कितना समय लगता है।कोबर्टुरा

... 
[junit] Running gov.nyc.doitt.gis.webmap.strategy.markup.ViewportDeterminingMarkupStrategyTest 
[junit] Tests run: 5, Failures: 0, Errors: 0, Time elapsed: 0.38 sec 
[junit] Flushing results... 
[junit] Flushing results done 
[junit] Cobertura: Loaded information on 282 classes. 
[junit] Cobertura: Saved information on 282 classes. 
[junit] Running gov.nyc.doitt.gis.webmap.strategy.markup.VisibleFeatureTypesMarkupInfoTest 
[junit] Tests run: 1, Failures: 0, Errors: 0, Time elapsed: 0.434 sec 
[junit] Flushing results... 
[junit] Flushing results done 
[junit] Cobertura: Loaded information on 282 classes. 
[junit] Cobertura: Saved information on 282 classes. 
[junit] Running gov.nyc.doitt.gis.webmap.strategy.markup.basemap.BasemapByViewportStrategyTest 
[junit] Tests run: 3, Failures: 0, Errors: 0, Time elapsed: 2.016 sec 
[junit] Flushing results... 
[junit] Flushing results done 
[junit] Cobertura: Loaded information on 282 classes. 
[junit] Cobertura: Saved information on 282 classes. 
[junit] Running gov.nyc.doitt.gis.webmap.strategy.markup.basemap.BasemapByZoomLevelAndCenterPointStrategyTest 
[junit] Tests run: 4, Failures: 0, Errors: 0, Time elapsed: 1.853 sec 
[junit] Flushing results... 
[junit] Flushing results done 
[junit] Cobertura: Loaded information on 282 classes. 
[junit] Cobertura: Saved information on 282 classes. 
... 

यह गड़बड़ लगता है कि हर परीक्षण चलाने के बाद Cobertura का कहना है::

:

[junit] Cobertura: Loaded information on 282 classes. 
[junit] Cobertura: Saved information on 282 classes. 
... 

यहाँ मेरी चींटी निर्माण स्क्रिप्ट से मेरी इकाई परीक्षण कार्य है

यहां नमूने कंसोल आउटपुट है

<target name="unit-test" depends="compile-unit-test"> 
    <delete dir="${reports.xml.dir}" /> 
    <delete dir="${reports.html.dir}" /> 
    <mkdir dir="${reports.xml.dir}" /> 
    <mkdir dir="${reports.html.dir}" /> 

    <junit fork="yes" dir="${basedir}" failureProperty="test.failed" printsummary="on"> 
     <!-- 
       Note the classpath order: instrumented classes are before the 
       original (uninstrumented) classes. This is important. 
      --> 
     <classpath location="${instrumented.dir}" /> 
     <classpath refid="test-classpath" /> 

     <formatter type="xml" /> 
     <test name="${testcase}" todir="${reports.xml.dir}" if="testcase" /> 
     <batchtest todir="${reports.xml.dir}" unless="testcase"> 
      <fileset dir="TestSource"> 
       <include name="**/*Test.java" /> 
       <exclude name="**/XmlTest.java" /> 
       <exclude name="**/ElectedOfficialTest.java" /> 
       <exclude name="**/ThematicManagerFixturesTest.java" /> 
      </fileset> 
     </batchtest> 
    </junit> 
</target> 

क्या मेरा सेटअप और आउटपुट सही लगता है? यूनिट परीक्षणों के लिए अकेले चलाने के दौरान 2.234 सेकेंड लेने के लिए सामान्य है और जब कोबर्टुरा के साथ बिल्ड स्क्रिप्ट में चलाया जाता है तो 3 मिनट लगते हैं?

+0

मैं नहीं दिख रहा है कि समस्या क्या (चींटी :-P का उपयोग कर के अलावा) है, लेकिन देरी के इस प्रकार निश्चित रूप से सामान्य नहीं है। –

+0

क्या मैं इसे एंट के अलावा अन्य पसंदीदा उपकरण लेता हूं? आप क्या सुझाव देंगे? –

+0

मैवेन और ग्रेडल चींटी पर दोनों बड़े सुधार हैं। एक मेवेन प्रोजेक्ट में कोबर्टुरा जोड़ना तुच्छ है। –

उत्तर

8

cobertura-anttask reference से:

इसी कारण से, आप तो आप चींटी 1.6.2 या उच्चतर उपयोग कर रहे हैं सेट forkmode करना चाह सकते हैं = "एक बार" यह करने के लिए केवल एक ही JVM का कारण होगा आपके सभी जुनीट परीक्षणों के लिए शुरू किया गया है, और कोबर्टुरा ओवरहेड को कम करेगा, जब भी JVM प्रारंभ/बंद हो जाता है तो कवरेज डेटा फ़ाइल को पढ़ना/लिखना।

(जोर मेरा है।)

+1

सही काम किया, धन्यवाद! –

संबंधित मुद्दे