草庐IT

android - 使用 android-maven-plugin 在 Eclipse 中进行简单的非 API Android JUnit 测试?

我每天都在Eclipse中运行非AndroidJUnit测试。今天我想测试我的一些Android库类。哦,痛苦。我有一个使用android-maven-plugin的Android库项目。我在src/main/java中有源文件,在src/test/java中有我的(新)单元测试。我的POM具有适当的JUnit依赖项和android-maven-plugin引用。有时我会从File创建一个AndroidUri实例。有时我有一个现有的JavaURI实例,它是从File创建的,然后我将其转换为Uri。由于我既不信任Java也不信任Android的文件和URI(不要让我开始了解Java如何破

android - 使用 Retrofit 的 RxJava JUnit 测试抛出 NullPointerException

我有一个retrofit2API调用publicinterfaceFeedService{@GET("/api/v1/feeds")ObservablegetFeeds(@Query("page")IntegerpageNumber,@Query("cats")Stringcategories,@Query("lang")Stringlanguage);}我有一个像这样使用这个API的存储库-publicclassFeedRepositoryImplimplementsFeedRepository{privatestaticFeedRepositoryImplINSTANCE;priv

首选项的 Android JUnit 测试

一个相当正常的场景:Android应用程序有一个首选项Activity,并且从ListPreference触发代码中选择一个选项以更改该ListPreference的摘要文本。即:从颜色ListPreference中选择“绿色”会通过onPreferenceChange回调将ListPreference的摘要文本更改为“绿色”。我希望能够使用AndroidJUnit测试来确认这些摘要更改是否全部正确执行。但是,关于如何执行此操作的信息似乎很少。我尝试了在ListPreference上使用setValue()的变体,在测试线程中和通过runOnUiThread()都没有成功-这不会触发对

使用 Robolectric : java. lang.InstantiationException 的 Android 库 JUnit 测试

尝试使用Robolectric在Android库项目上运行JUnit测试时出现以下错误:java.lang.RuntimeException:java.lang.InstantiationExceptionatcom.xtremelabs.robolectric.ApplicationResolver.newApplicationInstance(ApplicationResolver.java:56)atcom.xtremelabs.robolectric.ApplicationResolver.resolveApplication(ApplicationResolver.java:

java - Android Junit 测试位图资源

publicclassJamTest{ExplosionsEX=newExplosions(null);privateListexpList;Contextmtx;@BeforepublicvoidsetUpList(){expList=newArrayList(2);Bitmapbmp1=BitmapFactory.decodeResource(//resourceshere,R.drawable.ic_launcher);expList.add(bmp1);}@TestpublicvoidtestInit(){assertNull(EX.getListSize().get(0));

android - 为什么 Sonar 不在 Jenkins 上读取我的 JUnit XML 结果?

我正在尝试从我们持续集成Jenkins构建到Sonar中获取JUnit测试报告对于我们的Android项目。我离成功只有一步之遥,但我想不出最后一步。构建是用Ant完成的。我正在使用Jenkins-startedemulator并使用themissingandroidXMLJUnittestrunner运行测试.测试运行,我使用测试提供的说明成功地将JUnitXML结果文件(com.my.package.thing-TEST.xml等)从设备中提取到指定目录中运行者的作者。Sonar分析是使用TheJenkinsSonarplugin提供的“调用独立Sonar分析”构建步骤完成的.我已

android - 警告 : Conflict with dependency 'junit:junit' in project ':app' . 应用程序 (4.11) 和测试应用程序 (4.12) 的已解决版本

我正在尝试解决两个错误:无法解析符号“test”无法解析符号“AndroidJUnit4”在我的AndroidStudio项目中运行集成测试。为了解决这个问题,我看到了一些答案,我的build.gradle看起来像:applyplugin:'com.android.application'android{compileSdkVersion23buildToolsVersion'25.0.0'defaultConfig{applicationId"com.ps.comunio.comuniops"minSdkVersion15targetSdkVersion23versionCode1v

Android Espresso : Test filtering is not supported for given version of JUnit. 请将 JUnit 版本升级到至少 4.6

我真的不敢发布这个,但我在谷歌上没有找到任何相关的东西,所以我想这是一个菜鸟问题。我想使用Espresso来测试我的Android应用。我尝试下载示例项目,创建一个简单的项目并按照android开发者网站中的描述实现它,但我无法启动和运行它。我有构建工具22.0.1支持图书馆22手动添加静态导入后,我解决了示例测试中的所有编译问题。但是当我运行它时,我得到了这个::app:cleanTestUP-TO-DATE:app:preBuildUP-TO-DATE:app:preDebugBuildUP-TO-DATE:app:checkDebugManifest:app:preRelease

android - Robotium ClickOnButton(int ID) 方法导致 "junit.framework.AssertionFailedError: Button with index 2131034130 is not available!"

我正在使用robotium进行测试,无法弄清楚如何单击没有文本的按钮。测试失败,跟踪:junit.framework.AssertionFailedError:Buttonwithindex2131034130isnotavailable! 最佳答案 索引系统是出于黑盒测试的原因所以如果你知道你想点击的View的资源ID你可以使用solo.getView(R.id)来获取一个hold对象,然后使用solo.clickOnView(Viewview)单击它。 关于android-Robot

java - JUnit - 格式化字符串比较失败

我的单元测试失败并出现以下错误。对于此类问题,有什么比较宽松的方法可以通过测试吗?我不想更明确地指定DecimalFormatter,而是让测试更宽容。junit.framework.ComparisonFailure:expected:butwas:测试代码publicvoidtestCode(){Locale.setDefault(Locale.US);assertEquals("-0.31mm",codeUnderTest(-0.000314d);}生成字符串的代码在哪里privatestaticfinalintOFFSET_FRACTION_DIGITS_SI=2;privat