Skip to content
This repository was archived by the owner on Oct 26, 2022. It is now read-only.

Building Android Test Projects

charroch edited this page Jan 27, 2012 · 17 revisions

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:

 alias instrument = ;android:package-debug;android:install-device;tests/android:package-debug;tests/android:install-device;tests/android:test-device;

Or to use the emulator:

sbt android:package-debug android:install-emulator tests/android:package-debug tests/android:install-emulator tests/android:test-emulator
Clone this wiki locally