2013-08-14 10 views
5

Mam testy jednostkowe dla mojego projektu. Biegną grzywny w Eclipse, ale nie w mrówki z błędami:jNie test działa w środowisku Eclipse, ale kończy się niepowodzeniem w mrówce - java.lang.RuntimeException: Stub

java.lang.RuntimeException: Stub! 

Mam automatycznie wygenerowany mój ant build.xml z EclipseIDE acording do this artykułu.

Mój plik build.xml:

<?xml version="1.0" encoding="UTF-8" standalone="no"?> 
<project basedir="." default="main" name="MyProjectJavaTest"> 
    <property environment="env"/> 
    <property name="junit.output.dir" value="junit"/> 
    <property name="MyProject.location" value="../MyProject"/> 
    <property name="debuglevel" value="source,lines,vars"/> 
    <property name="target" value="1.6"/> 
    <property name="source" value="1.6"/> 

    <path id="JUnit 4.libraryclasspath"> 
     <pathelement location="../../../../../winapl/adt-bundle-windows-x86/eclipse/plugins/org.junit_4.8.2.v4_8_2_v20110321-1705/junit.jar"/> 
     <pathelement location="../../../../../winapl/adt-bundle-windows-x86/eclipse/plugins/org.hamcrest.core_1.1.0.v20090501071000.jar"/> 
    </path> 

    <path id="Android 4.2.libraryclasspath"> 
     <pathelement location="../../../../../winapl/adt-bundle-windows-x86/sdk/platforms/android-4.2/android.jar"/> 
    </path> 

    <path id="Android Dependencies.libraryclasspath"/> 
    <path id="Persisted container [com.android.ide.eclipse.adt.DEPENDENCIES for project [MyProject]].libraryclasspath"/> 
    <path id="MyProject.classpath"> 
     <pathelement location="${MyProject.location}/bin/classes"/> 
     <path refid="Android 4.2.libraryclasspath"/> 
     <path refid="Android Dependencies.libraryclasspath"/> 
     <path refid="Persisted container [com.android.ide.eclipse.adt.DEPENDENCIES for project [MyProject]].libraryclasspath"/> 
    </path> 

    <path id="MyProjectJavaTest.classpath"> 
     <pathelement location="bin"/> 
     <path refid="JUnit 4.libraryclasspath"/> 
     <path refid="MyProject.classpath"/> 
     <pathelement location="lib/java-json.jar"/> 
     <pathelement location="lib/httpcomponents/commons-codec-1.6.jar"/> 
     <pathelement location="lib/httpcomponents/commons-logging-1.1.1.jar"/> 
     <pathelement location="lib/httpcomponents/fluent-hc-4.2.5.jar"/> 
     <pathelement location="lib/httpcomponents/httpclient-4.2.5.jar"/> 
     <pathelement location="lib/httpcomponents/httpclient-cache-4.2.5.jar"/> 
     <pathelement location="lib/httpcomponents/httpcore-4.2.4.jar"/> 
     <pathelement location="lib/httpcomponents/httpmime-4.2.5.jar"/> 
    </path> 

      <target name="main" depends="MyProjectJavaTest,junitreport"/> 

    <target name="MyProjectJavaTest"> 
     <mkdir dir="${junit.output.dir}"/> 
     <junit fork="yes" printsummary="withOutAndErr"> 
      <formatter type="xml"/> 
      <test name="my.android.MyProject.api.F1U8GetTermsAndConditions" todir="${junit.output.dir}"/> 
      <test name="my.android.MyProject.api.JsonMarshallerTest" todir="${junit.output.dir}"/> 
      <test name="my.android.MyProject.api.ParamsTest" todir="${junit.output.dir}"/> 
      <test name="my.android.MyProject.api.TP1GetServiceDescriptionTest" todir="${junit.output.dir}"/> 
      <test name="my.android.MyProject.api.TP2GetServiceDescriptionLogoTest" todir="${junit.output.dir}"/> 
      <test name="my.android.MyProject.api.TP3GetServiceListTest" todir="${junit.output.dir}"/> 
      <test name="my.android.MyProject.api.TP4GetServiceLogoTest" todir="${junit.output.dir}"/> 
      <test name="my.android.MyProject.api.TP5GetSubscribedServiceInformationTest" todir="${junit.output.dir}"/> 
      <test name="my.android.MyProject.api.TP6GetSubscribedServiceListTest" todir="${junit.output.dir}"/> 
      <test name="my.android.MyProject.api.TP7SendServiceNotificationTest" todir="${junit.output.dir}"/> 
      <test name="my.android.MyProject.api.TP8SubscribeToServiceTest" todir="${junit.output.dir}"/> 
      <test name="my.android.MyProject.api.WMClientImplAndHMEIntegrationTest" todir="${junit.output.dir}"/> 
      <test name="my.android.MyProject.api.WMClientImplTest" todir="${junit.output.dir}"/> 
      <classpath refid="MyProjectJavaTest.classpath"/> 
     </junit> 
    </target> 

    <target name="junitreport"> 
     <junitreport todir="${junit.output.dir}"> 
      <fileset dir="${junit.output.dir}"> 
       <include name="TEST-*.xml"/> 
      </fileset> 
      <report format="frames" todir="${junit.output.dir}"/> 
     </junitreport> 
    </target> 
</project> 

mrówka wersja: 1.9.2

wersja JUnit: 4.8.2

Android Developer Tools Budowa: v21.0.0-531062

UPD: Mam następujący błąd:

UPD2: Ścieżka klas czasu wykonania i budowa ścieżki klas są takie same.

<?xml version="1.0" encoding="UTF-8"?> 
<classpath> 
    <classpathentry kind="src" path="src"/> 
    <classpathentry kind="con" path="org.eclipse.jdt.junit.JUNIT_CONTAINER/4"/> 
    <classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER"/> 
    <classpathentry kind="lib" path="lib/java-json.jar"/> 
    <classpathentry kind="lib" path="lib/httpcomponents/commons-codec-1.6.jar"> 
     <attributes> 
      <attribute name="javadoc_location" value="jar:platform:/resource/MyProjectLibJavaTest/lib/httpcomponents/javadoc.zip!/javadoc"/> 
     </attributes> 
    </classpathentry> 
    <classpathentry kind="lib" path="lib/httpcomponents/commons-logging-1.1.1.jar"> 
     <attributes> 
      <attribute name="javadoc_location" value="jar:platform:/resource/MyProjectLibJavaTest/lib/httpcomponents/javadoc.zip!/javadoc"/> 
     </attributes> 
    </classpathentry> 
    <classpathentry kind="lib" path="lib/httpcomponents/fluent-hc-4.2.5.jar"> 
     <attributes> 
      <attribute name="javadoc_location" value="jar:platform:/resource/MyProjectLibJavaTest/lib/httpcomponents/javadoc.zip!/javadoc"/> 
     </attributes> 
    </classpathentry> 
    <classpathentry kind="lib" path="lib/httpcomponents/httpclient-4.2.5.jar"> 
     <attributes> 
      <attribute name="javadoc_location" value="jar:platform:/resource/MyProjectLibJavaTest/lib/httpcomponents/javadoc.zip!/javadoc"/> 
     </attributes> 
    </classpathentry> 
    <classpathentry kind="lib" path="lib/httpcomponents/httpclient-cache-4.2.5.jar"> 
     <attributes> 
      <attribute name="javadoc_location" value="jar:platform:/resource/MyProjectLibJavaTest/lib/httpcomponents/javadoc.zip!/javadoc"/> 
     </attributes> 
    </classpathentry> 
    <classpathentry kind="lib" path="lib/httpcomponents/httpcore-4.2.4.jar"> 
     <attributes> 
      <attribute name="javadoc_location" value="jar:platform:/resource/MyProjectLibJavaTest/lib/httpcomponents/javadoc.zip!/javadoc"/> 
     </attributes> 
    </classpathentry> 
    <classpathentry kind="lib" path="lib/httpcomponents/httpmime-4.2.5.jar"> 
     <attributes> 
      <attribute name="javadoc_location" value="jar:platform:/resource/MyProjectLibJavaTest/lib/httpcomponents/javadoc.zip!/javadoc"/> 
     </attributes> 
    </classpathentry> 
    <classpathentry combineaccessrules="false" kind="src" path="/MyProjectLib"/> 
    <classpathentry kind="output" path="bin"/> 
</classpath> 
+1

Prawdopodobnie błąd ścieżki klasy, niektóre implementacje kodu pośredniczącego nie mogą zostać znalezione w środowisku wykonawczym. Dołącz pełny stacktrace. –

+0

@owlstead dodano do pytania –

+0

Może to być niekompatybilność między bibliotekami Androida i Apache. 'AbstractHttpParams' i' BasicHttpParams' są przestarzałe od wersji 4.3. Z tego względu może nawet zależeć od kolejności bibliotek na ścieżce klasowej. Android ma paskudny zwyczaj wysyłania pozbawionych bibliotek ... –

Odpowiedz

2

Problem pojawia się, gdy android.jar odwołuje przed junit.jar w ścieżce klasy.

W swojej build.xml kolejność wydaje się poprawne, ale określono identyfikator ze spacją w nim:

<path id="JUnit 4.libraryclasspath"> 

należy używać identyfikatorów bez spacji lub innych znaków specjalnych (.-_ Są ok, chociaż) .

Stacktrace w twoim UPD1 nie pokazuje żadnej junit, co jest kolejnym wskaźnikiem dla brakującej biblioteki.

Powiązane problemy