background preloader

Testing

Facebook Twitter

Loyolachicagocs_plsystems / clickcounter-android-scala. This example is intended as a starting point for anyone planning develop Android applications using Scala. Its learning objectives are: Android application development using Scalausing the Simple Build Tool (sbt) for Scalausing EclipseAndroid application architecture for testabilityDependency Inversion Principle (DIP)Model-View-Adapter architectural patternSeparation of Android activity into event-handling and lifecycle managementSeparation of imperative GUI and functional modelEffective testing Anticipated FAQs are included below.

Configure virtual machine hardware acceleration per these instructions.Create an Android Virtual Device (AVD) per these instructions. To start the emulator: $ emulator -avd YourAVD & It will take the emulator a couple of minutes to boot to your AVD's home or lock scren. HAX is working and emulator runs in fast virt mode To verify that you have a connection with the emulator: The resulting list should look like this: List of devices attachedemulator-5554 device Simply.

RoboSpecs - Android testing with Scala. I recently published Robospecs. Robospecs helps you write Android applications. Robospecs doesn't really do much itself. The real work is done by Robolectric and Specs2. Robolectric Robolectric lets you TDD your Android applications by giving you a way to run Android unit tests outside of an Android emulator.

Normal Android "unit" tests have to be executed inside an emulator. The android.jar files that Google provides as part of the Android SDK cannot be used to actually execute code such as unit tests. Robolectric provides an implementation of much of the Android components you would normally interact with and always a means to add additional implementations yourself for Android classes which aren't covered. Specs2 Specs2 is a great testing framework for Scala. Robospecs What Robospecs does is bridge the gap between Robolectric and Specs2. Example Project You can find a working, albeit very simple, sample Android project on GitHub at. Building Android Test Projects · jberkel/android-plugin Wiki. Building Android Test Projects Under construction (please feel free to fix this up) Put your Android test code in {project dir}/tests/src/main/(scala, java, AndroidManifest.xml, assets, res, etc.)

To build the tests, use sbt tests/android:package-debug Edit your project/build.scala to add the following missing lines as needed: ... settings = General.settings ++ AndroidTest.androidSettings ++ Seq( name := "MyScalaProjectTest", // You need to name your test project differently to avoid a circular dependency error libraryDependencies += "com.jayway.android.robotium" % "robotium-solo" % "2.4", // If you're using Robotium libraryDependencies += "junit" % "junit" % "3.8.2", // If you're using Junit ... ) dependsOn main To build the tests and run them on a device, try: sbt android:package-debug android:install-device tests/android:package-debug tests/android:install-device tests/android:test-device You can alias the above in the shell with the below: Or to use the emulator: and its alias: rebuild. ActivityInstrumentationTestCase2.

Class Overview This class provides functional testing of a single activity. The activity under test will be created using the system infrastructure (by calling InstrumentationTestCase.launchActivity()) and you will then be able to manipulate your Activity directly. Other options supported by this test case include: This class replaces ActivityInstrumentationTestCase, which is deprecated. New tests should be written using this base class.

If you prefer an isolated unit test, see ActivityUnitTestCase. Developer Guides For more information about application testing, read the Testing developer guide. Summary Public Constructors public ActivityInstrumentationTestCase2 (String pkg, Class<T> activityClass) Parameters public ActivityInstrumentationTestCase2 (Class<T> activityClass) Public Methods public T getActivity () Get the Activity under test, starting it if necessary. NOTE: Activities under test may not be started from within the UI thread. Returns the Activity under test Protected Methods. Android Testing with the Android Test framework, Robotium, Monkey and Robolectric. Android application testing with the Android test framework - Tutorial Copyright © 2011, 2012, 2013 Lars Vogel Android Testing This tutorial describes how to test Android applications with different Android testing frameworks. 1.

Android automated testing 1.1. Automated testing of Android applications is especially important because of the huge variety of available devices. Having a reasonable test coverage for your Android application helps you to enhance and maintain the Android application. 1.2. Android testing is based on JUnit. Which tests require an Android system is explained later in this book. Note The application which is tested is typically called the application under test. 1.3. A unit test tests only the functionality of a certain component. Let's, for example, assume a button in an Android activity is used to start another activity. Currently the Android testing API supports JUnit 3 and not JUnit 4. In JUnit 3 test methods must start with the test prefix. 1.5.

Table 1. 1.6. 1.7.