robotium

Flavors and instrumentation tests - gradle configuration

╄→гoц情女王★ 提交于 2019-12-01 12:16:51
I use flavors in my project and I wanna add add instrumentation tests specific for each flavor. So I created MyApplication/src/androidTestFlavor1/java/com.package.test MyApplication/src/androidTestFlavor2/java/com.package.test But it doesn't work correctly. So, I've tried to configure it in build.gradle, I've added android { ... sourceSets { flavor1{ instrumentTest.setRoot('src/instrumentationTestFlavor/java') } } ... } but I get error: Error:(59, 0) Could not find property 'instrumentTest' on source set ding. What's the best solution here? When you setup a new project in android studio it

Android, Robotium - Issue taking screenshot

北城以北 提交于 2019-12-01 11:44:14
I'm trying to take a screenshot of my Android application using Robotium, I'm using the below function that I found here . public static String SCREEN_SHOTS_LOCATION="/sdcard/"; public static void takeScreenShot(View view, String name) throws Exception { view.setDrawingCacheEnabled(true); view.buildDrawingCache(); Bitmap b = view.getDrawingCache(); FileOutputStream fos = null; try { File sddir = new File(SCREEN_SHOTS_LOCATION); if (!sddir.exists()) { sddir.mkdirs(); } fos = new FileOutputStream(SCREEN_SHOTS_LOCATION + name + "_" + System.currentTimeMillis() + ".jpg"); if (fos != null) { b

How to relaunch the closed app in Robotium?

泪湿孤枕 提交于 2019-12-01 09:38:50
I started to automate my Android app. It has a "Terms & conditions" screen. In that, if I click on "decline" , my app will be closed. How can I relaunch or restart my app within the same process? Try this: // assuming this method is in a ActivityInstrumentationTestCase2 class public void test_yourTest() { // do your testing Solo.sleep(1000); // killing all your Activities manually if it doesn't by itself anyway Solo.finishOpenedActivities(); // relaunch your app by calling the same Activity as in the constructor // of your ActivityInstrumentationTestCase2 this.launchActivity(TARGET_PACKAGE_ID,

Android, Robotium - Issue taking screenshot

允我心安 提交于 2019-12-01 09:18:15
问题 I'm trying to take a screenshot of my Android application using Robotium, I'm using the below function that I found here. public static String SCREEN_SHOTS_LOCATION="/sdcard/"; public static void takeScreenShot(View view, String name) throws Exception { view.setDrawingCacheEnabled(true); view.buildDrawingCache(); Bitmap b = view.getDrawingCache(); FileOutputStream fos = null; try { File sddir = new File(SCREEN_SHOTS_LOCATION); if (!sddir.exists()) { sddir.mkdirs(); } fos = new

How to relaunch the closed app in Robotium?

自作多情 提交于 2019-12-01 07:28:30
问题 I started to automate my Android app. It has a "Terms & conditions" screen. In that, if I click on "decline" , my app will be closed. How can I relaunch or restart my app within the same process? 回答1: Try this: // assuming this method is in a ActivityInstrumentationTestCase2 class public void test_yourTest() { // do your testing Solo.sleep(1000); // killing all your Activities manually if it doesn't by itself anyway Solo.finishOpenedActivities(); // relaunch your app by calling the same

Test run failed: Test run failed to complete. Expected 1 tests, received 0

人盡茶涼 提交于 2019-12-01 03:14:07
I tried starting a JUnit test (robotium) for my app: public class MainTest extends ActivityInstrumentationTestCase2<MainActivity> { private Solo solo; public MainTest() { super("nix.android.contact", MainActivity.class);// TODO Auto-generated constructor stub } protected void setUp() throws Exception { super.setUp(); solo = new Solo(getInstrumentation(), getActivity()); } public void AddContact() { solo.assertCurrentActivity("main", MainActivity.class); } } Manifest <instrumentation android:name="android.test.InstrumentationTestRunner" android:targetPackage="nix.android.contact" />

robotium Record

本秂侑毒 提交于 2019-12-01 01:10:36
1、安卓sdk 环境 2、下载robotium record 插件 3、 4、按步骤录制 有些时候sdk包是由签名的,我们需要重新签名。  为了顺利在测试设备上安装apk,我们需要对拿到的apk进行重新签名(Re-sign)。   重新签名的工具,网上很多,我使用的是re-sign.jar。   在用户目录下,会有一个.android的目录,把re-sign.jar放在该目录下。   Re-sign步骤如下:   1) 打开命令提示符:cmd   2) cd .../.android   3) 运行java -jar re-sign.jar,打开resign工具   4) 把最新的apk文件拖拽到打开的resign工具中,完成后,就会产生一个重新签名的apk文件。   Ps: resign后,会得到一个package name和main activity name,我们需要记下这两个名字,在第4步中会用到。3. 在模拟机中安装重新签名后的apk文件,步骤如下:(在真机中安装与模拟机类似,具体操作,Google或者Baidu即可)   1) 打开Android SDK安装目录   2) 找到sdk下的platform-tools目录   3) 把重新签名后的apk文件放在该目录下   4) 打开命令提示符:cmd   5) cd .../sdk/platform-tools   6)

(Robotium) Action bar up/home button click

☆樱花仙子☆ 提交于 2019-11-30 22:58:47
I use Robotium as the library for Junit test for my Android application. I wrote some tests which works well. But when I try to write a test for native ActionBar 's Up/Home button click , it failed. My test code is very simple: Solo solo = new Solo(getInstrumentation(), getActivity()); ... solo.clickOnActionBarHomeButton(); // I expected it will click the Up/Home button of ActionBar I expected the above code will click the Up/Home button of native ActionBar, but it is failed, nothing was happening on action bar. Why?? P.S. I am using an Android 4.2.1 device. I use this function: public void

Android Robotium NoClassDefFoundError

半城伤御伤魂 提交于 2019-11-30 17:53:21
I was just trying to use Robotium in an Android JUnit Test, but the Testing always fails with an error: java.lang.NoClassDefFoundError: com.jayway.android.robotium.solo.Solo thrown at solo = new Solo(getInstrumentation(), getActivity()); in the setUp() method: protected void setUp() throws Exception { super.setUp(); solo = new Solo(getInstrumentation(), getActivity()); } I read somewhere that this could be related to the Android SDK revision 17, but I cannot confirm this, as I first tried Robotium already with SDK 17. The Robotium jar is properly added to the project build path. Has anyone

5个最佳的Android测试框架

独自空忆成欢 提交于 2019-11-30 17:38:24
谷歌的Android生态系统正在不断地迅速扩张。有证据表明,新的移动OEM正在攻陷世界的每一个角落,不同的屏幕尺寸、ROM /固件、芯片组以及等等等等,层出不穷。于是乎,对于Android开发人员而言,处理存储碎片变得越来越困窘。 不过幸运的是,Android(还有iOS)开发人员可以无限制地访问一些先进的基于云的解决方案,如Testdroid Cloud,就可以在大规模的真实设备上执行自动化测试以确保质量,赞吧。此外,不同的Android测试框架的出现也大大减轻了Android开发人员的负担。 今天,我们就要说说5款最常用的Android测试框架,并且每个框架都给出了基本的代码示例。 1.Robotium 不可否认,Robotium曾是Android世界之初使用最广泛的Android测试框架,风靡一时。由于它与Android有着相似的Selenium,所以它能够使得API的测试变得简单起来。 Robotium是一个扩展于JUnit的开源库,运用多种有用的方法来支持Android UI测试。它提供的强大的自动化黑箱测试范例,可用于Android应用(原生的和混合的)和web测试。只要源代码允许,你就可以通过Robotium写功能、系统和验收测试方案,以及测试应用。 Robotium的代码示例: // Public void for the operation public void