Robolectric 似乎是一个非常有趣的替代 android 应用程序测试,但我无法将它与我的 Eclipse 环境正确集成。
使用最新的 robolectric 2.1 版和 android sdk 8,我按照 robolectric 网站上描述的 Eclipse 设置步骤进行操作,但没有成功。当我运行新创建的运行配置时,测试停止并出现以下错误。
我不明白为什么找不到我的 pakpak .R 类以及 ro.build.date.utc 是什么?症状还是问题?
WARNING: no system properties value for ro.build.date.utc
java.lang.RuntimeException: java.lang.ClassNotFoundException: com.googlecode.pakpak.android.R
at org.robolectric.AndroidManifest.getRClass(AndroidManifest.java:102)
at org.robolectric.AndroidManifest.getResourcePath(AndroidManifest.java:275)
at org.robolectric.AndroidManifest.getIncludedResourcePaths(AndroidManifest.java:280)
at org.robolectric.AndroidManifest.getIncludedResourcePaths(AndroidManifest.java:282)
at org.robolectric.RobolectricTestRunner.createAppResourceLoader(RobolectricTestRunner.java:590)
at org.robolectric.RobolectricTestRunner.getAppResourceLoader(RobolectricTestRunner.java:582)
at org.robolectric.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:66)
at org.robolectric.RobolectricTestRunner.setUpApplicationState(RobolectricTestRunner.java:392)
at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:232)
at org.junit.runners.ParentRunner.runLeaf(ParentRunner.java:263)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:68)
at org.junit.runners.BlockJUnit4ClassRunner.runChild(BlockJUnit4ClassRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:231)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:60)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:229)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:50)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:222)
at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:181)
at org.junit.runners.ParentRunner.run(ParentRunner.java:300)
at org.eclipse.jdt.internal.junit4.runner.JUnit4TestReference.run(JUnit4TestReference.java:50)
at org.eclipse.jdt.internal.junit.runner.TestExecution.run(TestExecution.java:38)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:467)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.runTests(RemoteTestRunner.java:683)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.run(RemoteTestRunner.java:390)
at org.eclipse.jdt.internal.junit.runner.RemoteTestRunner.main(RemoteTestRunner.java:197)
Caused by: java.lang.ClassNotFoundException: com.googlecode.pakpak.android.R
at java.net.URLClassLoader$1.run(URLClassLoader.java:366)
at java.net.URLClassLoader$1.run(URLClassLoader.java:355)
at java.security.AccessController.doPrivileged(Native Method)
at java.net.URLClassLoader.findClass(URLClassLoader.java:354)
at java.lang.ClassLoader.loadClass(ClassLoader.java:423)
at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:308)
at java.lang.ClassLoader.loadClass(ClassLoader.java:356)
at java.lang.Class.forName0(Native Method)
at java.lang.Class.forName(Class.java:188)
at org.robolectric.AndroidManifest.getRClass(AndroidManifest.java:100)
... 24 more
最佳答案
我有点解决了我的问题,我至少可以将测试运行到对我来说有意义的程度。在 Robolectric 2.0 中,它们允许您通过在测试项目中创建 Config.properties 文件来指定 AndroidManifest 文件的路径。
尝试这两个步骤,看看它们是否适合您:
在 org.robolectric.Config.properties 文件中添加行
manifest:[你的AndroidManifest.xml的相对路径]
我不得不稍微弄乱相对路径(不断添加/删除 ../'s),但这让它能够正确找到我的 AndroidManifest 文件。
您可以在 this github issue 找到更多信息或者他们的 configuring robolectric博客文章。我发现这两者都不够直接。
关于android - Robolectric 2.1 和 Eclipse,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16645885/
question的一些答案关于redirect_to让我想到了其他一些问题。基本上,我正在使用Rails2.1编写博客应用程序。我一直在尝试自己完成大部分工作(因为我对Rails有所了解),但在需要时会引用Internet上的教程和引用资料。我设法让一个简单的博客正常运行,然后我尝试添加评论。靠我自己,我设法让它进入了可以从script/console添加评论的阶段,但我无法让表单正常工作。我遵循的其中一个教程建议在帖子Controller中创建一个“评论”操作,以添加评论。我的问题是:这是“标准”方式吗?我的另一个问题的答案之一似乎暗示应该有一个CommentsController参
最近因为项目需要,需要将Android手机系统自带的某个系统软件反编译并更改里面某个资源,并重新打包,签名生成新的自定义的apk,下面我来介绍一下我的实现过程。APK修改,分为以下几步:反编译解包,修改,重打包,修改签名等步骤。安卓apk修改准备工作1.系统配置好JavaJDK环境变量2.需要root权限的手机(针对系统自带apk,其他软件免root)3.Auto-Sign签名工具4.apktool工具安卓apk修改开始反编译本文拿Android系统里面的Settings.apk做demo,具体如何将apk获取出来在此就不过多介绍了,直接进入主题:按键win+R输入cmd,打开命令窗口,并将路
我正在尝试在Eclipse中从事流浪者/厨师项目。我对这两种技术都很陌生,对ruby有点生疏。我已经安装了rdt并且有一个带有代码的ruby项目。然而,eclipse似乎并不理解gems是必需的。有没有办法让rubygems和eclipse一起玩得很好。我以为我可以将gems添加为库,但这似乎不起作用。 最佳答案 我在让Eclipse识别我安装的gem时遇到了一个非常相似的问题。我使用的是rvm,默认指向ruby2.1.0。我正在调试的ruby代码在顶部有一个require'mail'。运行或调试脚本时,控制台报错:
我正在为不同的应用程序使用多个ruby实例和gemset进行开发。为了在我的ruby版本和gemset之间切换,我使用.rvmrc文件。我还使用带有radrails插件的Eclipse作为我的开发工具。有什么方法可以让eclipse使用rvm在不同的gemsets和ruby版本之间自动切换? 最佳答案 Gointoyourprojectdirectoryandcreateafilecalled.rvmrccontainingtheline:rvmuseruby-1.8.7-p330@testing--default(or
同时Ruby1.9wascompilingtobytecode,它无法将预编译的脚本保存到磁盘。我们被告知期待Ruby2toallowsavingcompiledbytecode到磁盘,但我没有听到太多关于它的讨论,也没有看到无数的博客文章描述如何通过编译获得性能,我希望看到它是否真的在Ruby2.x的某个地方实现。AfocusedGooglesearch似乎没有返回任何有用的东西。在2.1(或更早版本)中可以吗?如果没有,这是否仍在路线图上? 最佳答案 有一半可能。从here下载扩展并编译它。需要库iseq.so好的,现在字节码的
我的代码必须解析Vcard2.1格式。我正在使用vpim(没有其他库)当我运行Vpim::Vcard.decode(data)时出现错误:undefinedmethod`each'for#堆栈跟踪:NoMethodError(undefinedmethod`each'for#):vpim(0.695)lib/vpim/rfc2425.rb:82:in`unfold'vpim(0.695)lib/vpim/rfc2425.rb:308:in`decode'vpim(0.695)lib/vpim/vcard.rb:692:in`decode'app/models/event.rb:71:i
我正在尝试在win7x64机器和ruby1.92环境上使用eclipsehelios(安装了dltk)调试ruby脚本我安装了ruby-debug19、ruby-debug-base19、ruby-debug-ide19gems,但仍然无法使用eclipsedlt调试rb脚本,如下所示,DebuggingEnginenotstartedThe'FastRubyDebugger(ruby-debug)'isselected,butthe'ruby-debug'gemdoesn'tseemtobeinstalledintheselectedRubyInterpreter(C:\
我正在使用Eclipse的Aptana3插件进行RubyonRails开发。我正在尝试使用ruby-debug-ide19gem在Eclipse中进行调试。我通过运行->调试为->Ruby应用程序启动调试session。这适用于最简单的场景。但是,如果我尝试访问我的任何模型、lib中的类等,它将无法工作,因为在调试之前没有加载我的开发环境。在进入Debug模式之前如何加载我的开发环境?就像我在命令行上执行railsconsole时发生的情况一样。如果我能让它正常工作,看起来会很不错。感谢您的帮助! 最佳答案 我使用Apatana
这听起来像是一个相当微不足道的问题,但我多年来一直在努力解决这个问题,放弃了Ruby又回到了它。我是一个尝试学习Ruby的Java/Eclipse人,所以我想在我的Win764位计算机上使用一些Eclipse插件调试jRuby/Rails。怎么这么难?我找不到分步说明(例如安装此插件、此版本的jRuby、安装这些gems、调整这些设置)。如果没有它,我就会碰碰运气,而且我所做的一切似乎都会导致奇怪的错误。此时,我正在尝试使用EasyEclipse(这是一个不错的选择吗?)。我发现默认安装(进入ProgramFiles)不是一个好主意,并将其安装在没有空格的路径中;与jRuby相同。我安
运行有问题或需要源码请点赞关注收藏后评论区留言一、利用ContentResolver读写联系人在实际开发中,普通App很少会开放数据接口给其他应用访问。内容组件能够派上用场的情况往往是App想要访问系统应用的通讯数据,比如查看联系人,短信,通话记录等等,以及对这些通讯数据及逆行增删改查。首先要给AndroidMaifest.xml中添加响应的权限配置 下面是往手机通讯录添加联系人信息的例子效果如下分成三个步骤先查出联系人的基本信息,然后查询联系人号码,再查询联系人邮箱代码 ContactAddActivity类packagecom.example.chapter07;importandroid