An open API service indexing awesome lists of open source software.

https://github.com/arquillian/arquillian-extension-android

Arquillian Android Platform Containers
https://github.com/arquillian/arquillian-extension-android

android arquillian java obsolete

Last synced: 6 months ago
JSON representation

Arquillian Android Platform Containers

Awesome Lists containing this project

README

          

# ![Obsolete](https://dummyimage.com/700x100/fff/f00&text=This%20Repository%20Is%20Obsolete!)

We don't maintain this code base anymore. If you are interested in picking it up from where we left please reach out to us through [Arquillian forum](http://discuss.arquillian.org/).

Arquillian Extension for the Android Platform
=============================================

This extensions allows you to bring Arquillian Drone WebDriver based testing to Android devices.
Extensions currently supports:

* Creating new Android Virtual Devices
* Reusing already existing Android Virtual Devices
* Connecting to real devices
* Injecting Android Device handler into test
* Using Arquillian Drone to control your test

Usage
-----

You have to do following steps, expecting your project was already set up to use Drone

0. Download Android SDK from http://developer.android.com/sdk/index.html and point ANDROID_HOME system variable to directory
where you extracted it. You should also update it via running `android` and navigating in the GUI.

1. Add Android extension to dependencies


org.jboss.arquillian.extension
arquillian-android-depchain
1.0.0.Final-SNAPSHOT
pom
test

*Note: Make sure you have **NOT** Arquillian Drone Selenium Server on the classpath, as it will collide with Android
unless configured to a different port. If you cannot remove it from classpath, you should disable it in `arquillian.xml`.



true

2. Download Android Server APK to be installed to you mobile device from http://code.google.com/p/selenium/downloads/list
Use `android-server-2.6.0.apk` for devices including Android 2.3.4, latest version for Android 3.0 and newer.

3. Set up WebDriver in arquillian.xml



org.openqa.selenium.android.AndroidDriver

http://localhost:14444/wd/hub

4. Set up Android in arquillian.xml

You should be aware that following might change in the future. You've been warned!



/home/kpiwko/apps/android-sdk-linux_x86

13
SnapshotEnabled
180

Properties explained, required in **bold**:

- **home** - ANDROID_HOME, can be ommited if set via ANDROID_HOME property
- **avdName** - name of the Android Virtual Device. It will be either created or reused
- apiLevel - (13) denotates API level, use `android list target` to get more variants
- serialId - replaces avdName if set and availabel, represents a real device. Use `adb devics` to get the list
- skip - (false) skip execution
- force - (false) force emulator recreationg
- sdSize - (128M) SD card size for emulator
- emulatorBootupTimeoutInSeconds - (180) maximal time to get emulator started, use Snapshot enabled device if it takes too long
- emulatorOptions - emulator options
- abi - specify ABI

Emulators are created by default in `${basedir}/${avdName}`.

5. Set up Android Drone in arquillian.xml

You should be aware that following might change in the future. You've been warned!


android-server-2.21.0.apk

Properties explained, required in **bold**:

- **androidServerApk** - path to the Android Server APK you've downloaded
- skip - (false) skip execution
- webdriverPortHost - (14444) port on Host connected with port on device
- webdriverPortGuest - (8080) port on Guest connected with port on Host

Interacting with Android Device from a test
-----------------------------------------

You have the possibility to inject an instance of `AndroidDevice` into test using `@ArquillianResource` annotation.
This is handy if you want for instance execute a shell command on the device or install an application, like in following:

@ArquillianResource AndroidDevice device;

@RunWith(Arquillian.class)
public class AndroidApkInstallationTestCase {

private final String INSTALLED_PACKAGES_CMD = "pm list packages";
private final String CALCULATOR_APP = "com.calculator";

@ArquillianResource
AndroidDevice device;

@Test
public void installAndUninstallApk() throws AndroidExecutionException {
device.installPackage(new File("src/test/apk/calculator.apk"), true);

List installedApps = getInstalledPackages(device);

Assert.assertTrue("Calculator app was installed", installedApps.contains(CALCULATOR_APP));

device.uninstallPackage(CALCULATOR_APP);

installedApps = getInstalledPackages(device);
Assert.assertFalse("Calculator app was uninstalled", installedApps.contains(CALCULATOR_APP));
}
}

Logging
-------

If you need to have more detailed logging, you have to provide logging.properties file as well as set it in Surefire plugin.
Logging file can look like:

handlers= java.util.logging.ConsoleHandler

.level= FINEST

java.util.logging.ConsoleHandler.formatter = java.util.logging.SimpleFormatter
java.util.logging.SimpleFormatter.format = %4$s: %5$s
java.util.logging.ConsoleHandler.level = FINEST

If you placed this file in `src/test/resources/logging.propreties`, Surefire execution will pick it up if following is defined:


...


maven-surefire-plugin


${project.build.testOutputDirectory}/logging.properties




...