- Java 双重比较
- java - 比较器与 Apache BeanComparator
- Objective-C 完成 block 导致额外的方法调用?
- database - RESTful URI 是否应该公开数据库主键?
我的项目有单元测试。它们在 Eclipse 中运行良好,但在 ant 中失败并出现错误:
java.lang.RuntimeException: Stub!
我已经根据 this 从 EclipseIDE 自动生成了我的 ant build.xml文章。
我的 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>
Ant 版本:1.9.2
junit 版本:4.8.2
Android 开发者工具版本:v21.0.0-531062
更新:我有以下错误:
java.lang.RuntimeException: Stub!
at org.apache.http.params.AbstractHttpParams.<init>(AbstractHttpParams.java:5)
at org.apache.http.params.BasicHttpParams.<init>(BasicHttpParams.java:6)
at my.android.myprojectlib.api.HttpClientProxyImpl.<init>(HttpClientProxyImpl.java:27)
at my.android.myprojectlib.api.HttpMethodExecutorImpl.<init>(HttpMethodExecutorImpl.java:28)
at my.android.myprojectlib.api.HttpMethodExecutorFactory.getHttpMethodExecutor(HttpMethodExecutorFactory.java:21)
at my.android.myprojectlib.api.WMClientImpl.<init>(WMClientImpl.java:66)
at my.android.myprojectlib.api.AbstractWMLibTest.setUp(AbstractWMLibTest.java:31)
UPD2:运行时类路径和构建类路径相同。
<?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>
最佳答案
当在类路径中的junit.jar
之前引用android.jar
时会出现问题。
在您的 build.xml
中,顺序似乎是正确的,但您指定的 id 中有一个空格:
<path id="JUnit 4.libraryclasspath">
您应该使用不带空格或其他特殊字符的 ID(不过,.-_ 没问题)。
您的 UPD1 中的堆栈跟踪显示没有 junit,这是缺少库的另一个迹象。
关于java - jUnit 测试在 Eclipse 中工作,但在 ant 中失败 - java.lang.RuntimeException : Stub,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18230115/
我真的很难弄明白这一点。当我查看 logcat 指向错误的位置时,它指向这一行: throw new RuntimeException(i); 在里面 public void onDetach() {
@Transactional (noRollbackFor=RuntimeException.class) public void methodA (Entity e){ service.met
我正在开发简历应用程序并遇到以下异常 在gradle文件上,我尝试了所有可能的解决方案,使缓存重启无效,并且干净的gradle不起作用 java.lang.RuntimeException:java.
我的项目在 Android Studio 3.0.1 上的 Whatchap 中,这是我的设计 gradle。build.gradle(应用程序) 应用插件:'com.android.applicat
// Top-level build file where you can add configuration options common to all sub-projects/modules.
您好,目前我正在开发包括解析服务器的项目,并且在将解析库添加到我的项目后,当我运行它时,它显示此错误,任务“:app:checkDebugDuplicateClasses”执行失败。 Exec
我找到了 another post显示我们如何创建我们自己的检查异常,它也返回不同于 500 的 HTTP 状态代码。但是,我需要它是一个 RuntimeException。然后,我找到了WebApp
我尝试在 7.40 系统上演示具有动态方法名称的 CALL METHOD 语句。我使用下面的测试代码,在第 27 行得到一个 ABAP 运行时错误。异常描述中的错误分析状态 ... 在类 LCL 中,
我的ViewModel类抛出了RunTimeException。它基本上不能创建ViewModel类的实例。这是堆栈跟踪: 2019-05-29 01:27:56.700 9698-9698/com.
我安装了Hive 0.9.0,运行它时出现错误: ./hive Logging initialized using configuration in jar:file:/usr/lib/hive-0.
当我尝试在 android 4.1.1(galaxy nexus)上运行 opencv(2.4.2) sample3时。我收到RuntimeException。 Logcat指向此处:(android
Java中除了RuntimeException之外还有其他可能发生的异常吗?谢谢。 最佳答案 是的,有三种种。 检查异常 编译器会让您知道何时可以抛出它们,很可能是由于环境中的故障。 如果程序可以
这个问题已经有答案了: Why runtime exception is unchecked exception? (5 个回答) 已关闭 7 年前。 我知道受检查的异常继承自 Exception并且
这里发生了什么? 为什么 IOException (RemoteException) 的检查子级会转换为 RuntimeException? 摘自here的片段 import java.rmi.Rem
源代码(osmand)没有错误 我使用了 eclipse 和 sdk 模拟器 2.2,从 googlecode checkout (osmand应用程序) 我的代码: public void onCr
我开始研究线程,我不明白为什么下面的简单代码不起作用。它正在抛出: RuntimeException: can't create handler inside thread that has not
我想为自己破例。但是当我抛出异常时,程序就关闭了。那么我怎样才能运行我的方法3次然后关闭程序呢? (我的程序在intArray之后关闭,但我想遍历dobleArray和charArray) 这是我的异
我有一个扩展 HttpServlet 的类包含以下两个方法。当客户端向 Tomcat 服务器上运行的 Web 应用程序发出请求时,http 请求将通过此类处理,但是如果 doSomething 方法抛
在很多地方,我都会遇到几个检查异常,例如 IOException、ParseException、JSONException 等。我必须做出两个选择 - 通过在方法签名末尾添加 throws 来引发相同
RuntimeExceptions 应该指示编程错误,我希望我的应用程序在我的可观察对象中的某些东西抛出 RuntimeException 时崩溃。 最好的方法是什么?现在我正在考虑这个解决方案(它是
我是一名优秀的程序员,十分优秀!