SlideShare una empresa de Scribd logo
1 de 40
Descargar para leer sin conexión
Robotium
Easy Black-box Testing
for Android
Renas Reda / Hugo Josefson
Agenda
●
Vanilla vs Robotium
– Instrumentation testing
– Write readable tests, with 10x less code [DEMO]
– (Still) access all the powers of Instrumentation [DEMO]
●
Darker than Black box [DEMO]
●
Robotium with Maven [DEMO]
●
The future of testing on Android
Black box testing?
• ...doesn't know how an application is designed
at the code level...
– bughuntress.com/analytics/glossary.html
• ...done without reference to the source code...
– www.sqablogs.com/jstrazzere/46/A+Glossary+of+Testing+Terms
.html
Instrumentation testing
Vanilla
vs
Robotium
Instrumentation Testing
(vanilla)
What's instrumentation testing?
• Investigate interaction with UI
• Pressing buttons, navigating menus
• Blackbox method(?)
• Takes time
• Can use JUnit
• Good for acceptance or system tests
• Can be automated!
Android built-in support
• Runs on device/emulator
• JUnit 3 compatible framework
• Allows direct control of user interface
–Touches
–Taps
–Scrolling in lists
• Can be started from Eclipse or shell
Android built-in support
• Tapping a view:
TouchUtils.tapView(someView)
• Pressing key (physical button):
getInstrumentation().
sendKeyDownUpSync(KeyEvent.KEYCODE_MENU)
• Sending text:
sendKeys(“some text”)
Drawbacks and limitations
• Required to know implementation details
• You often have to manually add
Thread.sleep(500) to make tests work
• Large apps can be very complex to test
• Tests run slowly
– Like if it would be done manually
– Not suitable for TDD
Setting up instrumentation tests
• Runs in emulator/device using JUnit 3
• Separate test project as normal
Writing an instrumentation test
Testing a Calculator GUI
Writing an instrumentation test
// Find views
EditText num1 = (EditText)
getActivity().findViewById(com.calculator.R.id.num1);
EditText num2 = (EditText)
getActivity().findViewById(com.calculator.R.id.num2);
Button addButton = (Button)
getActivity().findViewById(com.calculator.R.id.add_button);
// Perform instrumentation commands
TouchUtils.tapView(this, num1);
sendKeys(KeyEvent.KEYCODE_1,KeyEvent.KEYCODE_5);
TouchUtils.tapView(this, num2);
sendKeys(KeyEvent.KEYCODE_5);
TouchUtils.tapView(this, addButton);
// Fetch result and compare it against expected value
String actual = num1.getText().toString();
String expected = "20.0";
assertEquals("Addition incorrect", expected,actual);
Running instrumentation tests
• Started from Eclipse as “Android JUnit test”
• Can also be started from command line:
adb shell am instrument -w
com.package/android.test.InstrumentationTestRunner
Instrumentation testing
with
Robotium
Robotium
• Facts
– Instrumentation testing framework
– Add-on jar
– Open Source (Apache 2)
• Purpose
– Simplify making tests
• Benefits
– Easy to write, shorter code
– Automatic timing and delays
– Automatically follows current Activity
– Automatically finds Views
– Automatically makes own decisions
– when to scroll etc.
– No modification to Android platform
– Test execution is fast
• Current limitations
– Tied to JUnit 3 Instrumentation on device
– Tied to one app process
– Needs initial Activity(?)
Writing tests with Robotium
• You use only one class: Solo
• Test class like for normal instrumentation:
Remember the Calculator GUI?
Remember standard
instrumentation test?// Find views
EditText num1 = (EditText)
getActivity().findViewById(com.calculator.R.id.num1);
EditText num2 = (EditText)
getActivity().findViewById(com.calculator.R.id.num2);
Button addButton = (Button)
getActivity().findViewById(com.calculator.R.id.add_button);
// Perform instrumentation commands
TouchUtils.tapView(this, num1);
sendKeys(KeyEvent.KEYCODE_1,KeyEvent.KEYCODE_5);
TouchUtils.tapView(this, num2);
sendKeys(KeyEvent.KEYCODE_5);
TouchUtils.tapView(this, addButton);
// Fetch result and compare it against expected value
String actual = num1.getText().toString();
String expected = "20.0";
assertEquals("Addition incorrect", expected,actual);
Test Calculator with Robotium
public void testAdd() {
solo.enterText(0, "5");
solo.enterText(1,"3");
solo.clickOnButton("Add");
assertTrue(solo.searchEditText("8.0"));
}
Some Robotium commands
• clickOnButton(String regex)
• clickInList(int line)
• enterText(int index, String text)
• searchText(String regex)
• clickOnMenuItem(String regex)
• getCurrentActivity()
• goBack(), goBackToActivity(String name)
Writing Tests with Robotium
+ still access standard Instrumentation
[DEMO]
Darker than Black Box
Black box testing?
• ...doesn't know how an application is designed
at the code level...
– bughuntress.com/analytics/glossary.html
• ...done without reference to the source code...
– www.sqablogs.com/jstrazzere/46/A+Glossary+of+Testing+Terms
.html
The usual “Black box” way
• Two projects in Eclipse
– App project
– Test project
• Write test without looking at app's internals
The Darker than Black box way
• Any application's apk file
• One project in Eclipse
– App project
– Test project
• No access to original project
• Write test without any access to app's internals
Darker than Black Box
Test any APK w/o its source code
[DEMO]
Robotium with Maven
Maven
• Project management + Build tool
• Based on sane defaults
– Can be overridden with configuration
– Only configure what's different
• Plugins add functionality
– maven-android-plugin: build Android projects +
run Instrumentation tests
• Dependencies downloaded automatically
– Declare need for Robotium
→ Maven downloads jar
Declare need for Robotium
in test project
<dependency>
<groupId>com.jayway.android.robotium</groupId>
<artifactId>robotium-solo</artifactId>
<version>1.8.0</version>
</dependency>
Perform build and Run all Tests
including Robotium tests
$ mvn install
Maven with Robotium
Automating test execution
[DEMO]
The future of Testing
on Android
Google's Roadmap
?
Google's Roadmap
http://source.android.com/roadmap/
– Last entry “Beyond Q1 2009”:
– Support for WVGA and QVGA...
– Not keen on disclosing what they will /
will not release.
Google's Roadmap
http://source.android.com/roadmap/
– Last entry “Beyond Q1 2009”:
– Support for WVGA and QVGA...
– Page deleted
– Not keen on disclosing what they will /
will not release.
Robotium's Roadmap
for Instrumentation Testing
• Features we want to implement next
– Remote control
– Similar to Selenium RC
– Cucumber integration
– Generate screenshot on failure
– UI test coverage
• Features further down the line?
– Multidevice support
Robotium resources
Getting Started +
Robotium Developers discussion group:
www.robotium.org
Questions?
Robotium at Android Only 2010-09-29

Más contenido relacionado

La actualidad más candente

A guide to Android automated testing
A guide to Android automated testingA guide to Android automated testing
A guide to Android automated testingjotaemepereira
 
Utilizando Espresso e UIAutomator no Teste de Apps Android
Utilizando Espresso e UIAutomator no Teste de Apps AndroidUtilizando Espresso e UIAutomator no Teste de Apps Android
Utilizando Espresso e UIAutomator no Teste de Apps AndroidEduardo Carrara de Araujo
 
[AnDevCon 2016] Mutation Testing for Android
[AnDevCon 2016] Mutation Testing for Android[AnDevCon 2016] Mutation Testing for Android
[AnDevCon 2016] Mutation Testing for AndroidHazem Saleh
 
Getting Started with XCTest and XCUITest for iOS App Testing
Getting Started with XCTest and XCUITest for iOS App TestingGetting Started with XCTest and XCUITest for iOS App Testing
Getting Started with XCTest and XCUITest for iOS App TestingBitbar
 
Efficient JavaScript Unit Testing, JavaOne China 2013
Efficient JavaScript Unit Testing, JavaOne China 2013Efficient JavaScript Unit Testing, JavaOne China 2013
Efficient JavaScript Unit Testing, JavaOne China 2013Hazem Saleh
 
Selenium Automation Testing Interview Questions And Answers
Selenium Automation Testing Interview Questions And AnswersSelenium Automation Testing Interview Questions And Answers
Selenium Automation Testing Interview Questions And AnswersAjit Jadhav
 
Selenium interview questions and answers
Selenium interview questions and answersSelenium interview questions and answers
Selenium interview questions and answerskavinilavuG
 
Selenium Basics Tutorial
Selenium Basics TutorialSelenium Basics Tutorial
Selenium Basics TutorialClever Moe
 
Selenium notes
Selenium notesSelenium notes
Selenium noteswholcomb
 
LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)
LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)
LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)Bitbar
 
Testing android apps with espresso
Testing android apps with espressoTesting android apps with espresso
Testing android apps with espressoÉdipo Souza
 
Codeception introduction and use in Yii
Codeception introduction and use in YiiCodeception introduction and use in Yii
Codeception introduction and use in YiiIlPeach
 
Selenium interview-questions-freshers
Selenium interview-questions-freshersSelenium interview-questions-freshers
Selenium interview-questions-freshersNaga Mani
 
Introduction to Android Studio
Introduction to Android StudioIntroduction to Android Studio
Introduction to Android StudioMichael Pan
 
Acceptance & Functional Testing with Codeception - Devspace 2015
Acceptance & Functional Testing with Codeception - Devspace 2015 Acceptance & Functional Testing with Codeception - Devspace 2015
Acceptance & Functional Testing with Codeception - Devspace 2015 Joe Ferguson
 
Oh so you test? - A guide to testing on Android from Unit to Mutation
Oh so you test? - A guide to testing on Android from Unit to MutationOh so you test? - A guide to testing on Android from Unit to Mutation
Oh so you test? - A guide to testing on Android from Unit to MutationPaul Blundell
 

La actualidad más candente (20)

A guide to Android automated testing
A guide to Android automated testingA guide to Android automated testing
A guide to Android automated testing
 
Android testing part i
Android testing part iAndroid testing part i
Android testing part i
 
Android Test Automation Workshop
Android Test Automation WorkshopAndroid Test Automation Workshop
Android Test Automation Workshop
 
Utilizando Espresso e UIAutomator no Teste de Apps Android
Utilizando Espresso e UIAutomator no Teste de Apps AndroidUtilizando Espresso e UIAutomator no Teste de Apps Android
Utilizando Espresso e UIAutomator no Teste de Apps Android
 
[AnDevCon 2016] Mutation Testing for Android
[AnDevCon 2016] Mutation Testing for Android[AnDevCon 2016] Mutation Testing for Android
[AnDevCon 2016] Mutation Testing for Android
 
Getting Started with XCTest and XCUITest for iOS App Testing
Getting Started with XCTest and XCUITest for iOS App TestingGetting Started with XCTest and XCUITest for iOS App Testing
Getting Started with XCTest and XCUITest for iOS App Testing
 
Efficient JavaScript Unit Testing, JavaOne China 2013
Efficient JavaScript Unit Testing, JavaOne China 2013Efficient JavaScript Unit Testing, JavaOne China 2013
Efficient JavaScript Unit Testing, JavaOne China 2013
 
Selenium Automation Testing Interview Questions And Answers
Selenium Automation Testing Interview Questions And AnswersSelenium Automation Testing Interview Questions And Answers
Selenium Automation Testing Interview Questions And Answers
 
Selenium interview questions and answers
Selenium interview questions and answersSelenium interview questions and answers
Selenium interview questions and answers
 
Selenium Basics Tutorial
Selenium Basics TutorialSelenium Basics Tutorial
Selenium Basics Tutorial
 
Selenium notes
Selenium notesSelenium notes
Selenium notes
 
LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)
LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)
LDNSE: Testdroid for Mobile App and Web Testing (London Selenium Meetup)
 
Testing android apps with espresso
Testing android apps with espressoTesting android apps with espresso
Testing android apps with espresso
 
Codeception introduction and use in Yii
Codeception introduction and use in YiiCodeception introduction and use in Yii
Codeception introduction and use in Yii
 
Selenium interview-questions-freshers
Selenium interview-questions-freshersSelenium interview-questions-freshers
Selenium interview-questions-freshers
 
Introduction to Android Studio
Introduction to Android StudioIntroduction to Android Studio
Introduction to Android Studio
 
Testing In Java
Testing In JavaTesting In Java
Testing In Java
 
Acceptance & Functional Testing with Codeception - Devspace 2015
Acceptance & Functional Testing with Codeception - Devspace 2015 Acceptance & Functional Testing with Codeception - Devspace 2015
Acceptance & Functional Testing with Codeception - Devspace 2015
 
Selenium Handbook
Selenium HandbookSelenium Handbook
Selenium Handbook
 
Oh so you test? - A guide to testing on Android from Unit to Mutation
Oh so you test? - A guide to testing on Android from Unit to MutationOh so you test? - A guide to testing on Android from Unit to Mutation
Oh so you test? - A guide to testing on Android from Unit to Mutation
 

Similar a Robotium at Android Only 2010-09-29

A. Sirota "Building an Automation Solution based on Appium"
A. Sirota "Building an Automation Solution based on Appium"A. Sirota "Building an Automation Solution based on Appium"
A. Sirota "Building an Automation Solution based on Appium"DataArt
 
Unit testing and Android
Unit testing and AndroidUnit testing and Android
Unit testing and AndroidTomáš Kypta
 
Building an advanced automation solution based on Appium
Building an advanced automation solution based on AppiumBuilding an advanced automation solution based on Appium
Building an advanced automation solution based on AppiumAnton Sirota
 
Android Building, Testing and reversing
Android Building, Testing and reversingAndroid Building, Testing and reversing
Android Building, Testing and reversingEnrique López Mañas
 
How ANDROID TESTING changed how we think about Death - Second Edition
How ANDROID TESTING changed how we think about Death - Second EditionHow ANDROID TESTING changed how we think about Death - Second Edition
How ANDROID TESTING changed how we think about Death - Second EditionFernando Cejas
 
How ANDROID TESTING changed how we think about Death - Second Edition
How ANDROID TESTING changed how we think about Death - Second EditionHow ANDROID TESTING changed how we think about Death - Second Edition
How ANDROID TESTING changed how we think about Death - Second Editionpenanochizzo
 
Testing and Building Android
Testing and Building AndroidTesting and Building Android
Testing and Building AndroidDroidcon Berlin
 
Android testing
Android testingAndroid testing
Android testingBitbar
 
C++ Unit testing - the good, the bad & the ugly
C++ Unit testing - the good, the bad & the uglyC++ Unit testing - the good, the bad & the ugly
C++ Unit testing - the good, the bad & the uglyDror Helper
 
Effective Android Development. UA Mobile 2016.
Effective Android Development. UA Mobile 2016.Effective Android Development. UA Mobile 2016.
Effective Android Development. UA Mobile 2016.UA Mobile
 
2012 java one-con3648
2012 java one-con36482012 java one-con3648
2012 java one-con3648Eing Ong
 
Android testing
Android testingAndroid testing
Android testingJinaTm
 
When & How to Successfully use Test Automation for Mobile Applications
When & How to Successfully use Test Automation for Mobile ApplicationsWhen & How to Successfully use Test Automation for Mobile Applications
When & How to Successfully use Test Automation for Mobile ApplicationsTechnologyAssociationOregon
 
Detox: tackling the flakiness of mobile automation
Detox: tackling the flakiness of mobile automationDetox: tackling the flakiness of mobile automation
Detox: tackling the flakiness of mobile automationViktorija Sujetaitė
 
Automation using Javascript
Automation using JavascriptAutomation using Javascript
Automation using Javascriptkhanhdang1214
 
Effective Android Development
Effective Android Development Effective Android Development
Effective Android Development Sergii Zhuk
 
Uber Mobility Meetup: Mobile Testing
Uber Mobility Meetup:  Mobile TestingUber Mobility Meetup:  Mobile Testing
Uber Mobility Meetup: Mobile TestingApple Chow
 
Closer To the Metal - Why and How We Use XCTest and Espresso by Mario Negro P...
Closer To the Metal - Why and How We Use XCTest and Espresso by Mario Negro P...Closer To the Metal - Why and How We Use XCTest and Espresso by Mario Negro P...
Closer To the Metal - Why and How We Use XCTest and Espresso by Mario Negro P...Sauce Labs
 
Integration and Unit Testing in Java using Test Doubles like mocks and stubs
Integration and Unit Testing in Java using Test Doubles like mocks and stubsIntegration and Unit Testing in Java using Test Doubles like mocks and stubs
Integration and Unit Testing in Java using Test Doubles like mocks and stubsRody Middelkoop
 
Run somke test on AWS DeviceFarm
Run somke test on AWS DeviceFarmRun somke test on AWS DeviceFarm
Run somke test on AWS DeviceFarmNaoki AINOYA
 

Similar a Robotium at Android Only 2010-09-29 (20)

A. Sirota "Building an Automation Solution based on Appium"
A. Sirota "Building an Automation Solution based on Appium"A. Sirota "Building an Automation Solution based on Appium"
A. Sirota "Building an Automation Solution based on Appium"
 
Unit testing and Android
Unit testing and AndroidUnit testing and Android
Unit testing and Android
 
Building an advanced automation solution based on Appium
Building an advanced automation solution based on AppiumBuilding an advanced automation solution based on Appium
Building an advanced automation solution based on Appium
 
Android Building, Testing and reversing
Android Building, Testing and reversingAndroid Building, Testing and reversing
Android Building, Testing and reversing
 
How ANDROID TESTING changed how we think about Death - Second Edition
How ANDROID TESTING changed how we think about Death - Second EditionHow ANDROID TESTING changed how we think about Death - Second Edition
How ANDROID TESTING changed how we think about Death - Second Edition
 
How ANDROID TESTING changed how we think about Death - Second Edition
How ANDROID TESTING changed how we think about Death - Second EditionHow ANDROID TESTING changed how we think about Death - Second Edition
How ANDROID TESTING changed how we think about Death - Second Edition
 
Testing and Building Android
Testing and Building AndroidTesting and Building Android
Testing and Building Android
 
Android testing
Android testingAndroid testing
Android testing
 
C++ Unit testing - the good, the bad & the ugly
C++ Unit testing - the good, the bad & the uglyC++ Unit testing - the good, the bad & the ugly
C++ Unit testing - the good, the bad & the ugly
 
Effective Android Development. UA Mobile 2016.
Effective Android Development. UA Mobile 2016.Effective Android Development. UA Mobile 2016.
Effective Android Development. UA Mobile 2016.
 
2012 java one-con3648
2012 java one-con36482012 java one-con3648
2012 java one-con3648
 
Android testing
Android testingAndroid testing
Android testing
 
When & How to Successfully use Test Automation for Mobile Applications
When & How to Successfully use Test Automation for Mobile ApplicationsWhen & How to Successfully use Test Automation for Mobile Applications
When & How to Successfully use Test Automation for Mobile Applications
 
Detox: tackling the flakiness of mobile automation
Detox: tackling the flakiness of mobile automationDetox: tackling the flakiness of mobile automation
Detox: tackling the flakiness of mobile automation
 
Automation using Javascript
Automation using JavascriptAutomation using Javascript
Automation using Javascript
 
Effective Android Development
Effective Android Development Effective Android Development
Effective Android Development
 
Uber Mobility Meetup: Mobile Testing
Uber Mobility Meetup:  Mobile TestingUber Mobility Meetup:  Mobile Testing
Uber Mobility Meetup: Mobile Testing
 
Closer To the Metal - Why and How We Use XCTest and Espresso by Mario Negro P...
Closer To the Metal - Why and How We Use XCTest and Espresso by Mario Negro P...Closer To the Metal - Why and How We Use XCTest and Espresso by Mario Negro P...
Closer To the Metal - Why and How We Use XCTest and Espresso by Mario Negro P...
 
Integration and Unit Testing in Java using Test Doubles like mocks and stubs
Integration and Unit Testing in Java using Test Doubles like mocks and stubsIntegration and Unit Testing in Java using Test Doubles like mocks and stubs
Integration and Unit Testing in Java using Test Doubles like mocks and stubs
 
Run somke test on AWS DeviceFarm
Run somke test on AWS DeviceFarmRun somke test on AWS DeviceFarm
Run somke test on AWS DeviceFarm
 

Último

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptxHampshireHUG
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slidespraypatel2
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...Martijn de Jong
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdfhans926745
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)Gabriella Davis
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Drew Madelung
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking MenDelhi Call girls
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024Results
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonetsnaman860154
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Enterprise Knowledge
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...apidays
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxKatpro Technologies
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonAnna Loughnan Colquhoun
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slidevu2urc
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024The Digital Insurer
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Miguel Araújo
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 

Último (20)

04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
04-2024-HHUG-Sales-and-Marketing-Alignment.pptx
 
Slack Application Development 101 Slides
Slack Application Development 101 SlidesSlack Application Development 101 Slides
Slack Application Development 101 Slides
 
2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...2024: Domino Containers - The Next Step. News from the Domino Container commu...
2024: Domino Containers - The Next Step. News from the Domino Container commu...
 
[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf[2024]Digital Global Overview Report 2024 Meltwater.pdf
[2024]Digital Global Overview Report 2024 Meltwater.pdf
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)A Domino Admins Adventures (Engage 2024)
A Domino Admins Adventures (Engage 2024)
 
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
Strategies for Unlocking Knowledge Management in Microsoft 365 in the Copilot...
 
08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men08448380779 Call Girls In Civil Lines Women Seeking Men
08448380779 Call Girls In Civil Lines Women Seeking Men
 
A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024A Call to Action for Generative AI in 2024
A Call to Action for Generative AI in 2024
 
How to convert PDF to text with Nanonets
How to convert PDF to text with NanonetsHow to convert PDF to text with Nanonets
How to convert PDF to text with Nanonets
 
Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...Driving Behavioral Change for Information Management through Data-Driven Gree...
Driving Behavioral Change for Information Management through Data-Driven Gree...
 
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
Apidays Singapore 2024 - Building Digital Trust in a Digital Economy by Veron...
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law DevelopmentsTrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
TrustArc Webinar - Stay Ahead of US State Data Privacy Law Developments
 
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptxFactors to Consider When Choosing Accounts Payable Services Providers.pptx
Factors to Consider When Choosing Accounts Payable Services Providers.pptx
 
Data Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt RobisonData Cloud, More than a CDP by Matt Robison
Data Cloud, More than a CDP by Matt Robison
 
Histor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slideHistor y of HAM Radio presentation slide
Histor y of HAM Radio presentation slide
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024
 
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
Mastering MySQL Database Architecture: Deep Dive into MySQL Shell and MySQL R...
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 

Robotium at Android Only 2010-09-29

  • 1. Robotium Easy Black-box Testing for Android Renas Reda / Hugo Josefson
  • 2. Agenda ● Vanilla vs Robotium – Instrumentation testing – Write readable tests, with 10x less code [DEMO] – (Still) access all the powers of Instrumentation [DEMO] ● Darker than Black box [DEMO] ● Robotium with Maven [DEMO] ● The future of testing on Android
  • 3. Black box testing? • ...doesn't know how an application is designed at the code level... – bughuntress.com/analytics/glossary.html • ...done without reference to the source code... – www.sqablogs.com/jstrazzere/46/A+Glossary+of+Testing+Terms .html
  • 6. What's instrumentation testing? • Investigate interaction with UI • Pressing buttons, navigating menus • Blackbox method(?) • Takes time • Can use JUnit • Good for acceptance or system tests • Can be automated!
  • 7. Android built-in support • Runs on device/emulator • JUnit 3 compatible framework • Allows direct control of user interface –Touches –Taps –Scrolling in lists • Can be started from Eclipse or shell
  • 8. Android built-in support • Tapping a view: TouchUtils.tapView(someView) • Pressing key (physical button): getInstrumentation(). sendKeyDownUpSync(KeyEvent.KEYCODE_MENU) • Sending text: sendKeys(“some text”)
  • 9. Drawbacks and limitations • Required to know implementation details • You often have to manually add Thread.sleep(500) to make tests work • Large apps can be very complex to test • Tests run slowly – Like if it would be done manually – Not suitable for TDD
  • 10. Setting up instrumentation tests • Runs in emulator/device using JUnit 3 • Separate test project as normal
  • 13. Writing an instrumentation test // Find views EditText num1 = (EditText) getActivity().findViewById(com.calculator.R.id.num1); EditText num2 = (EditText) getActivity().findViewById(com.calculator.R.id.num2); Button addButton = (Button) getActivity().findViewById(com.calculator.R.id.add_button); // Perform instrumentation commands TouchUtils.tapView(this, num1); sendKeys(KeyEvent.KEYCODE_1,KeyEvent.KEYCODE_5); TouchUtils.tapView(this, num2); sendKeys(KeyEvent.KEYCODE_5); TouchUtils.tapView(this, addButton); // Fetch result and compare it against expected value String actual = num1.getText().toString(); String expected = "20.0"; assertEquals("Addition incorrect", expected,actual);
  • 14. Running instrumentation tests • Started from Eclipse as “Android JUnit test” • Can also be started from command line: adb shell am instrument -w com.package/android.test.InstrumentationTestRunner
  • 16. Robotium • Facts – Instrumentation testing framework – Add-on jar – Open Source (Apache 2) • Purpose – Simplify making tests
  • 17. • Benefits – Easy to write, shorter code – Automatic timing and delays – Automatically follows current Activity – Automatically finds Views – Automatically makes own decisions – when to scroll etc. – No modification to Android platform – Test execution is fast • Current limitations – Tied to JUnit 3 Instrumentation on device – Tied to one app process – Needs initial Activity(?)
  • 18. Writing tests with Robotium • You use only one class: Solo • Test class like for normal instrumentation:
  • 20. Remember standard instrumentation test?// Find views EditText num1 = (EditText) getActivity().findViewById(com.calculator.R.id.num1); EditText num2 = (EditText) getActivity().findViewById(com.calculator.R.id.num2); Button addButton = (Button) getActivity().findViewById(com.calculator.R.id.add_button); // Perform instrumentation commands TouchUtils.tapView(this, num1); sendKeys(KeyEvent.KEYCODE_1,KeyEvent.KEYCODE_5); TouchUtils.tapView(this, num2); sendKeys(KeyEvent.KEYCODE_5); TouchUtils.tapView(this, addButton); // Fetch result and compare it against expected value String actual = num1.getText().toString(); String expected = "20.0"; assertEquals("Addition incorrect", expected,actual);
  • 21. Test Calculator with Robotium public void testAdd() { solo.enterText(0, "5"); solo.enterText(1,"3"); solo.clickOnButton("Add"); assertTrue(solo.searchEditText("8.0")); }
  • 22. Some Robotium commands • clickOnButton(String regex) • clickInList(int line) • enterText(int index, String text) • searchText(String regex) • clickOnMenuItem(String regex) • getCurrentActivity() • goBack(), goBackToActivity(String name)
  • 23. Writing Tests with Robotium + still access standard Instrumentation [DEMO]
  • 25. Black box testing? • ...doesn't know how an application is designed at the code level... – bughuntress.com/analytics/glossary.html • ...done without reference to the source code... – www.sqablogs.com/jstrazzere/46/A+Glossary+of+Testing+Terms .html
  • 26. The usual “Black box” way • Two projects in Eclipse – App project – Test project • Write test without looking at app's internals
  • 27. The Darker than Black box way • Any application's apk file • One project in Eclipse – App project – Test project • No access to original project • Write test without any access to app's internals
  • 28. Darker than Black Box Test any APK w/o its source code [DEMO]
  • 30. Maven • Project management + Build tool • Based on sane defaults – Can be overridden with configuration – Only configure what's different • Plugins add functionality – maven-android-plugin: build Android projects + run Instrumentation tests • Dependencies downloaded automatically – Declare need for Robotium → Maven downloads jar
  • 31. Declare need for Robotium in test project <dependency> <groupId>com.jayway.android.robotium</groupId> <artifactId>robotium-solo</artifactId> <version>1.8.0</version> </dependency>
  • 32. Perform build and Run all Tests including Robotium tests $ mvn install
  • 33. Maven with Robotium Automating test execution [DEMO]
  • 34. The future of Testing on Android
  • 36. Google's Roadmap http://source.android.com/roadmap/ – Last entry “Beyond Q1 2009”: – Support for WVGA and QVGA... – Not keen on disclosing what they will / will not release.
  • 37. Google's Roadmap http://source.android.com/roadmap/ – Last entry “Beyond Q1 2009”: – Support for WVGA and QVGA... – Page deleted – Not keen on disclosing what they will / will not release.
  • 38. Robotium's Roadmap for Instrumentation Testing • Features we want to implement next – Remote control – Similar to Selenium RC – Cucumber integration – Generate screenshot on failure – UI test coverage • Features further down the line? – Multidevice support
  • 39. Robotium resources Getting Started + Robotium Developers discussion group: www.robotium.org Questions?