Arquillian Android Extensions
Java Scala
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
archetypes
build
droidium-container
droidium-native
droidium-platform
droidium-recorder
droidium-screenshooter
resources
tests
.gitignore
README.adoc
pom.xml

README.adoc

Arquillian Droidium - ftesting of Android done right

This is the home of the following extensions for Arquillian testing platform:

Arquillian Droidium container

Implementation of Arquillian container abstraction for Android devices. By this Arquillian container adapter, you can execute tests dealing with Android devices where Android device is considered to be just another Arquillian container.

Arquillian Droidium platform

This tiny extension provides core Android platform configuration on which Droidium container depends.

Arquillian Droidium Native

Extension for supporting testing of native applications for Droidium container. You need this extension when you want to functionally test your native Android application. Native extension relies on Selendroid project from where it takes Selendroid server APK.

Arquillian Droidium Recorder

By this extension, you can make videos of Android devices while you are executing tests.

Arquillian Droidium Screenshooter

By this extension, you can take screenshots of Android devices while you are executing tests.

Examples

Note
You are welcome to look at intensive test scenarios in tests directory in this repository where every possible scenario Droidium is able to do is shown with fully runnable examples.
@RunWith(Arquillian.class)
@RunAsClient
public class AndroidContainerTest {

    // injected abstraction of your Android device
    @ArquillianResource
    AndroidDevice android;

    // APK will be deployed to android device
    // upon Android container startup
    @Deployment
    public static Archive<?> createAndroidDeployment() {
        return ShrinkWrap.createFromZipFile(
            JavaArchive.class, new File(my.apk));
    }

    @Test
    public void test01() {
        assertTrue(android != null);

        String sn = android.getSerialNumber();
        String avdName = android.getAvdName();

        Assert.assertTrue(android.isOnline());
        Assert.assertFalse(android.isOffline());

        boolean emulator = android.isEmulator();

        // command and package management
        android.executeShellCommand("execute on android");
        android.createPortForwarding(localPort,remotePort);
        android.installPackage();
        android.uninstallPackage();
        android.isPackageInstalled("package name");

        // taking screenshots and record videos
        Screenshot screenshot = android.getScreenshot();

        android.startRecording(remoteFilePath, options);
        Video video = android.stopRecording(localFilePath);

        // push, pull and remove file to and from device
        android.push(localFilePath, remoteFilePath);
        android.pull(remoteFilePath, localFilePath);
        android.remove(remoteFilePath);
    }
}

Complete information how to use Android container can be found here.

@RunAsClient
@RunWith(Arquillian.class)
public class NativeAndroidTestCase {

    @Drone
    AndroidDriver mobile;

    @Deployment
    @Instrumentable // instruments APK by Selendroid server
    public static Archive<?> getDeployment() {
        return ShrinkWrap.createFromZipFile(JavaArchive.class,
            new File("my.apk"));
    }

    @Test
    public void test() {
        mobile.startActivity("my.fqcn.of.activity");
    }
@RunAsClient
@RunWith(Arquillian.class)
public class MultipleContainersTest {

    @Drone
    @FirstApp
    AndroidDriver mobile_1;

    @Drone
    @SecondApp
    AndroidDriver mobile_2;

    @Deployment
    @Instrumentable // instruments APK by Selendroid server
    @TargetsContainer("android-1")
    public static Archive<?> getDeployment_1() {
        return ShrinkWrap.createFromZipFile(JavaArchive.class,
            new File("my_first.apk"));
    }

    @Deployment
    @Instrumentable(port = 8081) // instruments APK by Selendroid server
    @TargetsContainer("android-2")
    public static Archive<?> getDeployment_2() {
        return ShrinkWrap.createFromZipFile(JavaArchive.class,
            new File("my_second.apk"));
    }

    @Test
    @InSequence(1)
    public void test() {
        mobile_1.startActivity("my.fqcn.of.activity");
    }

    @Test
    @InSequence(2)
    public void test_2() {
        mobile_2.startActivity("my.fqcn.of.activity");
    }

In your arquillian.xml, you just specify two containers and two Drones.

<arquillian>
    <group qualifier="containers" default="true">
        <container qualifier="android_1" default="true">
            <configuration>
                <property name="avdName">my_first_avd</property>
            </configuration>
        </container>
        <container qualifier="android_2">
            <configuration>
                <property name="avdName">my_second_avd</property>
            </configuration>
        </container>
    </group>

    <extension qualifier="webdriver-firstapp">
        <property name="browser">android</property>
        <property name="remoteAddress">http://localhost:8080/wd/hub</property>
    </extension>

    <extension qualifier="webdriver-secondapp">
        <property name="browser">android</property>
        <property name="remoteAddress">http://localhost:8081/wd/hub</property>
    </extension>
</arquillian>

Lastly you have to create two annotations - FirstApp and SecondApp. You find information how to create them here

What we done in the example above is that you deploy my_first.apk to my_first_avd, my_second.apk to my_second_avd, and you have two Drones hence you control my_first.apk by Drone annotated with FirstApp and you control the second app by SecondApp Drone. Class scoped Drones can be used in one test method together. Note that in case you do these Drones class scoped, Selendroids are deployed only once for the whole test case. However in case you inject them as method scoped, underlying Selendroid server would be deployed and undeployed every test method hence performance-wise it would be little bit slower.

Complete information how to use Android Native plugin for ftesting can be found here.

Arquillian Recorder integration

This extension builds on top of Arquillian Recorder so by using above recorder and screenshooter extensions, these resources will appear in resulting exporter report in e.g. html file.

Cordova tests

Droidium can run Cordova tests as well. Droidium is able to test everything Selendroid is able to test since it is based on it.

Runtime dependencies

You have to have installed Android SDK locally on your machine and you have to set it up fully.

Be sure you set all environment properties like ANDROID_HOME and ANDROID_SDK_HOME+m +JAVA_HOME and HOME.

You have to have Java installed locally as well. Droidium is developed against Java 1.6.

Example projects

Example project which show various usecases of Droidium are the part of this project and can be found here:

You can generate your own project via archetypes. They can be found here

How to install Arquillian Droidium?

mvn clean install

How to use Android container native application testing?

Please find respective README and configuration documentation in its respective directory. You can find archetypes for native testing in archetype directory so you can boostrap your testing process significantly faster. You can also take a look into tests directory. There is bunch of example projects how to use it with very deep documentation.

How to generate Javadoc?

mvn javadoc:aggregate

JIRA & Issue tracker

You are welcome to raise your issues at JBoss JIRA for Droidium component: