robotium

can wifi be switched on/off in test case through robotium

ε祈祈猫儿з 提交于 2019-12-05 04:35:07
can we switch on/off the wi-fi of the device in a test cases in robotium? because i am testing an issue which needs wifi to be on in initial phase then turning off the wi-fi and continue with testing. Yes you can do it, see the example: public void testNoNetworkConnection() throws Exception { setWifiEnabled(false); // do stuff solo.something setWifiEnabled(true); } private void setWifiEnabled(boolean state) { WifiManager wifiManager = (WifiManager)solo.getCurrentActivity().getSystemService(Context.WIFI_SERVICE); wifiManager.setWifiEnabled(state); } Remember to add permission in your Manifest

Android & Robotium - Test activity that expects an extra?

こ雲淡風輕ζ 提交于 2019-12-04 22:37:40
It seems to me that robotium was designed in a way to test 1 Activity at a time instead of the whole application. So my question is how do I test an activity that expects an extra to be passed to it? by extra I mean intent.putExtra("Something", object); The method setActivityIntent(Intent) should be what you are looking for. I used this method to provide a custom Intent to my Activity's TestCase. Just use it after you call super in your constructor. Intent i = new Intent(); i.putExtra("myExtra", "anyValue"); setActivityIntent(i); You don't have to do it in the constructor i think, but you need

How to inject click event with Android UiAutomation.injectInputEvent

强颜欢笑 提交于 2019-12-04 13:27:45
问题 I'm automating the testing of a flow in my app where I install a device administrator. To activate a device administrator on most devices (let's assume here I don't have some enterprise API that lets me do this like what Samsung offers) the system displays a popup to the user who then has to click the "Activate" button. I'm using Robotium and Android JUnit to drive my tests. In a normal testing case one can only interact with the app and process under test and not any system activities that

Robotium - testing specific flavors in Android Studio with Gradle

≡放荡痞女 提交于 2019-12-04 06:26:56
问题 So... i'm trying to make some tests for my application. I have several flavors in my application, and I want to build individual tests for each flavor. From the Robotium documentation I used the "androidTest/java" folder with a package inside... I event tried after some suggestions to input a flavor's .test. Another suggestion from here: http://tools.android.com/tech-docs/new-build-system/user-guide was to make several folders named "androidTest", but it didn't worked. I have the latest

How do I click the first item in a spinner using Robotium?

ぐ巨炮叔叔 提交于 2019-12-04 05:27:27
问题 I am having problems scrolling up in a spinner to select the first item in a Robotium test case. Here is my code: int pos = solo.getCurrentSpinners().get(0).getSelectedItemPosition(); solo.pressSpinnerItem(0, 0 - pos); pos is 1 when I debug, but Robotium still presses the spinner on index 1 even though I order it to press on -1. What am I doing wrong? Thanks Markus 回答1: Seems they took those classes out now. Just ran into this myself but found a way to do this properly and generically. // 0

Android Robotium: how to go back to my Activity under test after clicking/launching another Activity

二次信任 提交于 2019-12-04 04:16:47
问题 I have an issue with my Robotium tests. On one of my Activity A, I am clicking on a button. Clicking on this button launches another activity B. So in my robotium test I have something like this : Button myBtn = (Button) solo.getView(R.id.myBtn); so after this action, the emulator is automatically launching activity B. Now, the problem is that I do not have any possibility of going back to the activity under test (A) in the code. Can you please tell me how to avoid getting jailed in the

Android test project is crashing with error “Test run failed: Instrumentation run failed due to 'Process crashed.'”

牧云@^-^@ 提交于 2019-12-04 00:02:31
My problem seems little different than here Test run failed: Instrumentation run failed due to 'Process crashed.' when testing multiple Android activity I have followed steps given in the pdf . I have created test project "TestAndroidCalculatorBlackbox" (do we need to have two project one test and one main project, perhaps this could be the reason, cause in Robotium "Getting Started" link they want us to create projects for Notepad), and added jars robotium-solo-5.0.1.jar , robotium-solo-1.6.0.jar , to get rid of red error lines below solo. functions and jay.way package . I am attaching the

Android studio 下的robotium自动化测试和持续集成

岁酱吖の 提交于 2019-12-03 13:36:30
一、前言 Android Studio 是一个Android开发环境,基于 I ntelliJ IDEA . 类似 Eclipse ADT ,Android Studio 提供了集成的 Android 开发工具用于开发和调试。作为官方主推的开发环境和停止对其他开发IDE的支持,Android Studio将成为今后唯一的android开发环境。本文主要介绍在Android Studio环境下的 Robotium 测试框架 使用方法和持续集成。 二、在Android Studio中使用Robotium 2.1 基础环境配置 先来看一下Android Studio中的工程结构,如下图所示: Android Studio 建立的工程会自带一个测试包,如图所示,androidTest即为测试包,测试用例就放在这个包内。如果项目目录内无此测试包,也可直接在src目录下创建test/java目录。创建完成后,检查build.gradle文件查看是否加入了junit4依赖,如果没有就做加入如下配置: dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:22.1.1' testCompile 'junit:junit:4.12' } 2

Unable to get Robotium to work in Android Studio

夙愿已清 提交于 2019-12-03 08:19:41
问题 I'm struggling to get Robotium to work on the gradle-based Android Studio and I can't find the way to do it This is my build.gradle file buildscript { dependencies { repositories { mavenCentral() mavenLocal() } classpath 'com.android.tools.build:gradle:0.5.+' } } apply plugin: 'android' repositories { mavenCentral() /* maven { url "https://oss.sonatype.org/content/repositories/snapshots" }*/ } sourceSets { testLocal { java.srcDir file('src/test/java') resources.srcDir file('src/test/resources

Interface Android robotium testing with Teamcity

*爱你&永不变心* 提交于 2019-12-03 07:43:53
问题 As this was not answered (Maybe did I not find it) previously, I investigated on the following question : How to perform automated functional tests on Android devices with robotium, and report them to continuous integration server like TeamCity? 回答1: As I did not find any answer on that specific question, I investigated. Here is the output of my investigation and a quick How-To in order to help people perform automated functional tests on Android applications using robotium, and then report