2010-05-10 13 views
5

मैं एक्लिप्स का उपयोग कर एक ग्रहण एसडब्ल्यूटी एप्लीकेशन विकसित कर रहा हूं। कुछ जुनीट 4 परीक्षण भी हैं, जो कुछ डीएओ का परीक्षण करते हैं। लेकिन जब मैं चींटी निर्माण के माध्यम से परीक्षण चलाने की कोशिश करता हूं, तो सभी परीक्षण विफल हो जाते हैं, क्योंकि परीक्षण कक्षाएं नहीं मिलती हैं।फिर भी एक और चींटी + जुनीट क्लासपाथ समस्या

Google ने लगभग दस लाख लोगों को लाया जो सभी को एक ही समस्या है, लेकिन उनके कोई भी समाधान मेरे लिए काम नहीं करता है.-.-।

ये मेरी build.xml फ़ाइल की सामग्री हैं:

<property name="test.reports" value="./test/reports" /> 
<property name="classes" value="build" /> 


<path id="project.classpath"> 
    <pathelement location="${classes}" /> 
</path> 

<target name="testreport"> 
    <mkdir dir="${test.reports}" /> 
    <junit fork="yes" printsummary="no" haltonfailure="no"> 
     <batchtest fork="yes" todir="${test.reports}" > 
      <fileset dir="${classes}"> 
       <include name="**/Test*.class" /> 
      </fileset> 
     </batchtest> 
     <formatter type="xml" /> 

     <classpath refid="project.classpath" /> 


    </junit> 

    <junitreport todir="${test.reports}"> 
     <fileset dir="${test.reports}"> 
      <include name="TEST-*.xml" /> 
     </fileset> 
     <report todir="${test.reports}" /> 
    </junitreport> 
</target> 

परीक्षण कक्षाओं का निर्माण निर्देशिका में हालांकि वे अपने पैकेजों के अनुसार कुछ सबफ़ोल्डर में हैं, आवेदन वर्गों के साथ एक साथ कर रहे हैं।

शायद यह भी महत्वपूर्ण है: पहली चींटी ने शिकायत की कि जुनीट अपने क्लासपाथ में नहीं था, लेकिन जब से मैंने इसे वहां रखा (ग्रहण कॉन्फ़िगरेशन एडिटर के साथ) यह शिकायत करता है कि जुनीट अपने क्लासपाथ में दो बार है।

WARNING: multiple versions of ant detected in path for junit 
    [junit]   jar:file:C:/Users/as df/Documents/eclipse/plugins/org.apache.ant_1.7.1.v20090120-1145/lib/ant.jar!/org/apache/tools/ant/Project.class 
    [junit]  and jar:file:/C:/Users/as%20df/Documents/eclipse/plugins/org.apache.ant_1.7.1.v20090120-1145/lib/ant.jar!/org/apache/tools/ant/Project.class 

मैं हर उपनिर्देशिका, प्रत्येक और हर वर्ग फ़ाइल को निर्दिष्ट करने की कोशिश की है, मैं कोशिश की है फ़ाइलसेट और filelists, कुछ भी नहीं काम करने के लिए लगता है।

आपकी मदद के लिए धन्यवाद, मैं इस बात अब पर घंटे के लिए बैठे किया गया है ...

+0

क्या आप "as dd" के बजाय उपयोगकर्ता नाम "as_df" लिखना चाहते हैं (अंडरस्कोर द्वारा खाली स्थानांतरित करना)? – stacker

उत्तर

3

मुझे वही समस्या थी जो जूनिट के पथ में चींटी के कई संस्करणों का पता चला था। समस्या तब चली गई जब मैंने Eclipse_Home निर्देशिका का नाम बदल दिया और इससे विशेष वर्ण हटा दिए। पथ में '[1]' था जो समस्या पैदा कर रहा था।

1

यह चींटी build.xml मेरे लिए ठीक काम करता है। यह देखने के लिए गुणों की जांच करें कि निर्देशिका संरचना आपकी मेल खाती है या नहीं; आवश्यकतानुसार समायोजित करें।

<?xml version="1.0" encoding="UTF-8"?> 
<project name="xslt-converter" basedir="." default="package"> 

    <property name="version" value="1.6"/> 
    <property name="haltonfailure" value="no"/> 

    <property name="out" value="out"/> 

    <property name="production.src" value="src"/> 
    <property name="production.lib" value="lib"/> 
    <property name="production.resources" value="config"/> 
    <property name="production.classes" value="${out}/production/${ant.project.name}"/> 

    <property name="test.src" value="test"/> 
    <property name="test.lib" value="lib"/> 
    <property name="test.resources" value="config"/> 
    <property name="test.classes" value="${out}/test/${ant.project.name}"/> 

    <property name="exploded" value="out/exploded/${ant.project.name}"/> 
    <property name="exploded.classes" value="${exploded}/WEB-INF/classes"/> 
    <property name="exploded.lib" value="${exploded}/WEB-INF/lib"/> 

    <property name="reports.out" value="${out}/reports"/> 
    <property name="junit.out" value="${reports.out}/junit"/> 
    <property name="testng.out" value="${reports.out}/testng"/> 

    <path id="production.class.path"> 
     <pathelement location="${production.classes}"/> 
     <pathelement location="${production.resources}"/> 
     <fileset dir="${production.lib}"> 
      <include name="**/*.jar"/> 
      <exclude name="**/junit*.jar"/> 
      <exclude name="**/*test*.jar"/> 
     </fileset> 
    </path> 

    <path id="test.class.path">        
     <path refid="production.class.path"/> 
     <pathelement location="${test.classes}"/> 
     <pathelement location="${test.resources}"/> 
     <fileset dir="${test.lib}"> 
      <include name="**/junit*.jar"/> 
      <include name="**/*test*.jar"/> 
     </fileset> 
    </path> 

    <path id="testng.class.path"> 
     <fileset dir="${test.lib}"> 
      <include name="**/testng*.jar"/> 
     </fileset> 
    </path> 

    <available file="${out}" property="outputExists"/> 

    <target name="clean" description="remove all generated artifacts" if="outputExists"> 
     <delete dir="${out}" includeEmptyDirs="true"/> 
     <delete dir="${reports.out}" includeEmptyDirs="true"/> 
    </target> 

    <target name="create" description="create the output directories" unless="outputExists"> 
     <mkdir dir="${production.classes}"/> 
     <mkdir dir="${test.classes}"/> 
     <mkdir dir="${reports.out}"/> 
     <mkdir dir="${junit.out}"/> 
     <mkdir dir="${testng.out}"/> 
     <mkdir dir="${exploded.classes}"/> 
     <mkdir dir="${exploded.lib}"/> 
    </target> 

    <target name="compile" description="compile all .java source files" depends="create"> 
     <!-- Debug output 
       <property name="production.class.path" refid="production.class.path"/> 
       <echo message="${production.class.path}"/> 
     --> 
     <javac srcdir="src" destdir="${out}/production/${ant.project.name}" debug="on" source="${version}"> 
      <classpath refid="production.class.path"/> 
      <include name="**/*.java"/> 
      <exclude name="**/*Test.java"/> 
     </javac> 
     <javac srcdir="${test.src}" destdir="${out}/test/${ant.project.name}" debug="on" source="${version}"> 
      <classpath refid="test.class.path"/> 
      <include name="**/*Test.java"/> 
     </javac> 
    </target> 

    <target name="junit-test" description="run all junit tests" depends="compile"> 
     <!-- Debug output 
       <property name="test.class.path" refid="test.class.path"/> 
       <echo message="${test.class.path}"/> 
     --> 
     <junit printsummary="yes" haltonfailure="${haltonfailure}"> 
      <classpath refid="test.class.path"/> 
      <formatter type="xml"/> 
      <batchtest fork="yes" todir="${junit.out}"> 
       <fileset dir="${test.src}"> 
        <include name="**/*Test.java"/> 
       </fileset> 
      </batchtest> 
     </junit> 
     <junitreport todir="${junit.out}"> 
      <fileset dir="${junit.out}"> 
       <include name="TEST-*.xml"/> 
      </fileset> 
      <report todir="${junit.out}" format="frames"/> 
     </junitreport> 
    </target> 

    <taskdef resource="testngtasks" classpathref="testng.class.path"/> 
    <target name="testng-test" description="run all testng tests" depends="compile"> 
     <!-- Debug output 
       <property name="test.class.path" refid="test.class.path"/> 
       <echo message="${test.class.path}"/> 
     --> 
     <testng classpathref="test.class.path" outputDir="${testng.out}" haltOnFailure="${haltonfailure}" verbose="2" parallel="methods" threadcount="50"> 
      <classfileset dir="${out}/test/${ant.project.name}" includes="**/*.class"/> 
     </testng> 
    </target> 

    <target name="exploded" description="create exploded deployment" depends="testng-test"> 
     <copy todir="${exploded.classes}"> 
      <fileset dir="${production.classes}"/> 
     </copy> 
     <copy todir="${exploded.lib}"> 
      <fileset dir="${production.lib}"/> 
     </copy> 
    </target> 

    <target name="package" description="create package file" depends="exploded"> 
     <jar destfile="${out}/${ant.project.name}.jar" basedir="${production.classes}" includes="**/*.class"/> 
    </target> 

</project> 
+0

एचएम समस्या के हल किए गए पेट की तरह लगता है, लेकिन अब मुझे "फोर्कड जावा वीएम असामान्य रूप से बाहर निकला है। कृपया ध्यान दें कि रिपोर्ट में समय वीएम निकास तक समय को प्रतिबिंबित नहीं करता है" – DeX3

6

मुझे यह केवल तब मिल रहा था जब जूनिट कार्य में 'फोर्क = सत्य' विकल्प का उपयोग किया गया था। ऐसा इसलिए हो रहा था क्योंकि मेरे ANT_HOME में '..' था (उदा। '/3rdparth/jboss/jboss-5/../tools')। एक बार जब मैंने उस पथ को कम कर दिया, तो 'चींटी के कई संस्करण' चेतावनी चली गईं।

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