Loading presentation...

Present Remotely

Send the link below via email or IM


Present to your audience

Start remote presentation

  • Invited audience members will follow you as you navigate and present
  • People invited to a presentation do not need a Prezi account
  • This link expires 10 minutes after you close the presentation
  • A maximum of 30 users can follow your presentation
  • Learn more about this feature in our knowledge base article

Do you really want to delete this prezi?

Neither you, nor the coeditors you shared it with will be able to recover it again.


Robotium + Ant + Jenkins

No description

Ryun Ong

on 14 May 2014

Comments (0)

Please log in to add your comment.

Report abuse

Transcript of Robotium + Ant + Jenkins

Robotium + Ant + Jenkins

Install AUT (Application Under Test) APK apk file on emulator/device

Create Test Project using eclipse to test that apk

Test Android apk file with Robotium

Need to sign apk file in debug mode

Step 1:
  Rename the APK as zip.
Step 2:
Delete META-INF folder
Step 3:
Make the full folder into a ZIP file
Step 4:
Rename into apk extension
Step 5:
open command prompt. and write the command
jarsigner -keystore [source keystore with path]
-storepass android -keypass android [source apk with path] androiddebugkey

Step 6:
This is optional , it is necessary if apk is not installed properly. This will align the content inside the apk. 

Before installing….

Launch your emulator using cmd line

Install your AUT apk on the emulator

Install AUT apk on Emulator

Type your project name

Create a new android test project

Create Test Project

Select build target and click finish

Select This project

We will manually create package by right click on project select New > Package. On 'New Java Package' window fill package name against 'Name:'.
In this example we use com.test as package name

Eclipse will create a TestProject without package.

Create a test class under the package.

Inside the testDisplayBlackBox() class is where we will write our test script.

And all the available classes in the Solo library can be found at:

In the test class, we will have to provide the package id and activity class name . By running the apk file in the emulator/device, we can get the name of the package and activity from cmd logcat.

In the manifest file, add the instrumentation line.

into the project
which can be download at:

After complete verification it will
show the report as following

Run the TestProject as Android Junit Test in the eclipse-
it will automatically load EPOD.TTI5.apk (installed on emulator)

ANT is used for building, archiving and distributing after you’ve done your codes in your IDE.
Ant is also widely used in Continuous Integration such as Jenkins/Hudson.

Repeatable Builds
All members of the team can run the same exact build script with the same exact result.
If you rely on your IDE, your setup could be slightly different to mine which could cause differences in our builds.

Why Ant?

Step 1)Download ant
Step 2)Extract to your local drive C:\ (or anywhere you want)
Step 3) Add Ant to your System Variable
Right click computer ->properties -> Advanced system settings - >
Under Advanced Tab Click Environment Variables -> Click ‘New’
Step 4) Edit Path and Add Ant \bin path

Installing Ant

Set up your app project (no need to do if you don’t have source code for the app)
android update project -p <your project directory>

Run cmd and change to your adb directory

Setup Ant to your project

Set up your library project (if you use library for your apps)
android update lib-project –path <your library project diretory>

Set up your test project
android update test-project -m <app project directory> -p <test project directory>

Setup Ant to your project

Run this 2 line to test
ant clean debug
ant debug install test

Now to test it with ant, run cmd and change to your test project directory

By now build.xml, local.properties and ant.properties should be generated at your app project,
test project and library directory.

Testing the project with Ant

It should run the test and show BUILD SUCCESSFUL

Testing the project with Ant

Jenkins is the new Hudson.
Hudson/Jenkins is all about the plugins.
Plugin developers have moved to Jenkins and so should we.
The crew that has been developing Hudson is now working on Jenkins
More people have moved to jenkins. Therefore,
it is easier for us to search for documentation and tutorials because of a larger user community.
Frequent update such as fixing bugs, improvement in codes and more features

Why Jenkins?

Step 1)
Download .war file, create a folder “jenkins” in your
local drive C:\ and paste .war file there.
Step 2)
Run your cmd and change directory to C:\jenkins and run this line below
java –jar jenkins.war
Step 3)
Connect to jenkins by typing http://localhost:8080/
in your browser
Step 4)
If you want jenkins to connect automatically as a service
Go to Jenkins ->Manage Jenkins -> Install as Windows Service

Installing Jenkins

Go to Manage Jenkins -> Configure System
Set Home Directory to jenkins and add SDK path

Configure Jenkins

Go to Manage Jenkins -> Manage Plugin ->Available

Install the following:
-Android Emulator Plugin
-Subversion Plugin
-Copy Artifact Plugin
-Log Parser Plugin
-File System SCM
-Green Balls

Install plugins in Jenkins

Click on New Item on the left side of jenkins
Name it “Demo1” for example
Choose Build a free –style software project and click ok

Create app project job

Click Add Build Step and choose Invoke Ant
Follow the picture below and add your directory

Choose File System and add path to your app project directory

Create app project job

Create a new Demo1Test job

Create test project job

Click Add Build Step and choose Invoke Ant
Follow the picture below and add your directory

Choose File System and add path to your test project directory

Create test project job

Click Add Build Step and choose Install Android Package
Add path to app apk and another to test apk

Create test project job

cd <adb directory>
adb shell am instrument -w <test package name>/android.test.InstrumentationTestRunner

Click Add Build Step and select Execute Windows batch command
Enter the command line below:

Create test project job

You can see any errors and execution process in the console output
Go to Build History -> Demo1Test -> Your latest build under Build History -> Console Output

After you have configure and save both job
Execute the project by clicking on Build Now
It should look like this

Test and build job

Under Demo1Test job configuration
Click on Add -> Post Build Action

Create a new text file, include this 2 line and save as ErrorReport.rule
Go to Manage Jenkins -> Configure System
Under Console Output Parsing

Configure Log Parser

If there is error in the your test case it should look like this

Error Report
Full transcript