Questions tagged [android-testing]

The Android testing framework

The Android testing framework, an integral part of the development environment, provides an architecture and powerful tools that help you test every aspect of your application at every level from unit to framework.

The testing framework has these key features:

  • Android test suites are based on JUnit. You can use plain JUnit to test a class that doesn't call the Android API, or Android's JUnit extensions to test Android components. If you're new to Android testing, you can start with general-purpose test case classes such as AndroidTestCase and then go on to use more sophisticated classes.
  • The Android JUnit extensions provide component-specific test case classes. These classes provide helper methods for creating mock objects and methods that help you control the lifecycle of a component.
  • Test suites are contained in test packages that are similar to main application packages, so you don't need to learn a new set of tools or techniques for designing and building tests.
  • The SDK tools for building and tests are available in Eclipse with ADT, and also in command-line form for use with other IDEs. These tools get information from the project of the application under test and use this information to automatically create the build files, manifest file, and directory structure for the test package.
  • The SDK also provides monkeyrunner, an API for testing devices with Python programs, and UI/Application Exerciser Monkey, a command-line tool for stress-testing UIs by sending pseudo-random events to a device.
2161 questions
1
vote
1 answer

Android Testing AsyncTask with TextView Passed in

I have an AsyncTask that I would like to write a test for. It has a TextView that is passed in: public LoadAssetTask(TextView target, boolean skipSingleLineBreak, InputStream in) { ...} How do I write an Adroid JUnit test for this? Is there a way…
JPM
  • 9,077
  • 13
  • 78
  • 137
1
vote
0 answers

Read data (as USB data) from PC when Android device is connected to PC

I am working on a project where we are developing an Android app to read data from an RFID chip in an USB. The Android app works fine, reads the RFID data when the USB(with the RFID chip) is connected to the Android device. But I want to test the…
Gadenkan
  • 1,691
  • 2
  • 17
  • 29
1
vote
2 answers

Android ActivityInstrumentationTestCase2 NullPointerException on getting context

I have an ActivityInstrumentationTestCase2 and I have had no luck getting context for the test. package com.vsnetworks.vsnmedia.test; import org.json.JSONObject; import android.app.Activity; import android.content.Context; import…
s.field212
  • 75
  • 2
  • 11
1
vote
1 answer

Can't run android junit tests on a real device

I'm running an Android test project from eclipse. The project run on the emulator. If I attach my device eclipse doesn't give me the choice to run the test project on it, but I can run my application on it from eclipse. Is there some setting I need…
alex
  • 3,412
  • 2
  • 28
  • 36
1
vote
1 answer

Robolectric: test Cookies in HttpResponse

I'm using Robolectric to test my Android application. I'm trying write a test to verify that my Android app correctly receives cookies from a HttpResponse. I tried a few options, but could't get it to work. Here is what I try in the…
1
vote
2 answers

Android Testing of an Activity not run by JUnit

I'm trying to do Android unit testing for the first tme and I encounter a problem I can't seem to solve : only one of my test classes is ran, I'm not able to run test classes related to Activity testing, and even asserting true=false in them doesn't…
Aweb
  • 174
  • 3
  • 15
1
vote
0 answers

How to test my dbmanager class in android?

In my android app I am using ormlite. Now I want to create some testcases for the db helper methods. I do not know how this should work properly. The database need to be created in my testcase before the concrete test can start. For example I want…
Al Phaba
  • 6,545
  • 12
  • 51
  • 83
1
vote
5 answers

java.lang.NoClassDefFoundError for FragmentActivity class when running Robotium

I've tried everything I could think of, but still I cannot run my tests using Robotium. I set the robotium library and my main project to be exported in the Project configuration as suggested here I've set the android:debuggable flag to true as…
1
vote
1 answer

Robolectric: findViewById returns null

I'm trying to do a very simple test with Robolectric, I want to test if a view exists. which is very similar to the examples in Robolectric's website, but findViewById keeps returning null. what can be the problem ? this is the activity: public…
Gal Ben-Haim
  • 17,433
  • 22
  • 78
  • 131
1
vote
1 answer

Android WebDriver does not load https pages using the Android Test Framework

How do you load https pages on Android WebDriver with the Android Test Framework on an AVD? According to the AndroidDriver FAQ (http://code.google.com/p/selenium/wiki/AndroidDriver#Android_fails_to_load_HTTPS_pages) you need to enable capabilities…
1
vote
0 answers

How can I to write unit-test for my android method?

I wrote some code. Now I need to write unit-test for it. I do not know how to write it for this method: public void parceAuthResult() { NodeList nodeList = baseDocElement.getElementsByTagName("LoginResult"); if(nodeList != null &&…
romiope
  • 756
  • 8
  • 11
1
vote
1 answer

most common android devices for each

There is a fair amount of information available on Android operating system version adoption and which versions are most common (ex. here) Is there a resource containing similar information about physical device characteristics based on popularity? …
paul smith
  • 1,327
  • 4
  • 17
  • 32
1
vote
4 answers

Android source folders

I have an Android project which has a "src" source folder, and I also created a "test" source folder. The 2 folders have a package of the same name inside them. I added an activity to the test folder and set it as the main activity, but Android…
user940016
  • 2,878
  • 7
  • 35
  • 56
1
vote
1 answer

SparseIntArray doesn't change when being tested with Robolectric

I'm new to Robolectric and I'm trying to unit test a simple getter/setter code, but it seems that the SparseIntArray isn't working as expected when testing with Robolectric and it simply doesn't change. (i always get '0' with the get method). I also…
Gal Ben-Haim
  • 17,433
  • 22
  • 78
  • 131
1
vote
0 answers

Strange NullPointerException at Android SpinnerActivityTest

I was lately working with the Activity Testing Tutorial on androids developer site. By following the step-by-step guide up to Adding UI tests - 1. you get this code snippet: package com.android.example.spinner.test; import…
Johannes Staehlin
  • 3,680
  • 7
  • 36
  • 50
1 2 3
99
100