SlideShare ist ein Scribd-Unternehmen logo
1 von 19
Downloaden Sie, um offline zu lesen
TESTING ANDROID
                                     Marc Chung
                                      OpenRain
                              marc.chung@openrain.com




Friday, August 28, 2009                                 1
Agenda


                   Introduce Android testing concepts

                   Unit and mock testing + Demos

                   Android testing overview + Demos

                   Q&A




Friday, August 28, 2009                                 2
Unit testing in Java

                   JUnit is the most popular framework

                   Most projects, frameworks, IDEs will ship with support

                   Out of the box, Eclipse IDE has good JUnit support

                   There are many frameworks
                          http://en.wikipedia.org/wiki/List_of_unit_testing_frameworks#Java




Friday, August 28, 2009                                                                       3
Unit testing demo


                   Twitter Demo

                          Uses JUnit

                          Login/password

                          Update status




Friday, August 28, 2009                                4
public void testStatusUpdate() {
                   try {
                     IMyTwitter twitter = new MyTwitter("supertesting", "s3!kretep@s5");
                     TwitterClient client = new TwitterClient(twitter);
                     String update = "Hello Phoenix Android";
                     client.post(update);
                     Assert.assertEquals(update, client.getLatestPost());
                   } catch (TwitterException te) {
                     Assert.fail("Shouldn't see this because the credentials are correct");
                   }
                 }




Friday, August 28, 2009                                                                       5
Mock Objects in Java

                   A Mock is “fake” object which mimics real objects for the
                   purpose of testing

                   Mimics real objects for testing

                   Such as a web service request

                   Mocking is a style of testing
                          http://martinfowler.com/articles/mocksArentStubs.html




Friday, August 28, 2009                                                           6
Mock testing demo


                   Twitter Demo

                          Uses EasyMock

                          Avoid issuing live requests




Friday, August 28, 2009                                 7
public void testStatusUpdate() {	
                             String updateStatus = "Hello Phoenix Android";

                              IMyTwitter mockedTwitter = EasyMock.createMock(IMyTwitter.class);
                              expect(mockedTwitter.getStatus()).andReturn(null);
                              expect(mockedTwitter.updateStatus(updateStatus)).andReturn(null);

                    	     	   replay(mockedTwitter);

                    	     	   TwitterClient client = new TwitterClient(mockedTwitter);
                    	     	   client.post(updateStatus);
                    	     	   Assert.assertEquals(updateStatus, client.getLatestPost());

                    	     	   verify(mockedTwitter);
                    	     }




Friday, August 28, 2009                                                                           8
Android Testing


                   Testing Android requires JUnit

                   Write tests to run and test parts of your application

                   InstrumentationTestRunner runs your test as an application

                          Executes code on emulator




Friday, August 28, 2009                                                         9
Setting up your project
                      Using the command line tool will create a tests/ directory
                      inside the project.
                          android create project -t 3 -n hello_world -p hello_world -a HelloWorld -k com.openrain.hello_world


                      Use Eclipse manually.

                          Doesn’t create a tests/ directory

                          Manually create two projects.




Friday, August 28, 2009                                                                                                         10
Running Android tests


                   Two ways to run your tests

                          Command line runner

                          Eclipse runner




Friday, August 28, 2009                               11
AndroidTestCase


                   unit testing

                   faster and easier to boot strap

                   only have access to a Context

                   useful for asserting layout, position, and components




Friday, August 28, 2009                                                    12
ActivityInstrumentationTestCase


                   functional unit testing

                   access to a real live Activity instance

                   may simulate key events

                   slower




Friday, August 28, 2009                                      13
Instrumentation Demo



                   Functional tests

                          Test drives the Activity




Friday, August 28, 2009                              14
Other Android tests
                   ServiceTestCase

                          For testing services

                   ActivityUnitTestCase and ActivityTestCase

                          For testing an Activity in isolation

                   ApplicationTestCase

                          Full integration testing


Friday, August 28, 2009                                          15
More Android testing


                   Testing APIs
                          http://developer.android.com/reference/android/test/package-summary.html

                             android.test

                             android.test.mock




Friday, August 28, 2009                                                                              16
Tips


                   Isolate and test non-Android code separately.

                   Functional tests use live objects. Slow, but reliable.

                   Javadoc is your friend




Friday, August 28, 2009                                                     17
Future topics


                   Code coverage tools

                   Continuous integration tools

                   Performance testing




Friday, August 28, 2009                            18
Thank you


                   Join Phoenix Android Mailing list

                          http://phoenixandroid.com

                   Follow me on Twitter:

                          @heisenthought




Friday, August 28, 2009                                19

Weitere ähnliche Inhalte

Was ist angesagt?

Testing on Android
Testing on AndroidTesting on Android
Testing on AndroidAri Lacenski
 
Test driven development - JUnit basics and best practices
Test driven development - JUnit basics and best practicesTest driven development - JUnit basics and best practices
Test driven development - JUnit basics and best practicesNarendra Pathai
 
Renaissance of JUnit - Introduction to JUnit 5
Renaissance of JUnit - Introduction to JUnit 5Renaissance of JUnit - Introduction to JUnit 5
Renaissance of JUnit - Introduction to JUnit 5Jimmy Lu
 
Open Source Test Workshop for QA Testers, Developers, IT Managers
Open Source Test Workshop for QA Testers, Developers, IT ManagersOpen Source Test Workshop for QA Testers, Developers, IT Managers
Open Source Test Workshop for QA Testers, Developers, IT ManagersClever Moe
 
JUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkJUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkOnkar Deshpande
 
Unit Testing with JUnit4 by Ravikiran Janardhana
Unit Testing with JUnit4 by Ravikiran JanardhanaUnit Testing with JUnit4 by Ravikiran Janardhana
Unit Testing with JUnit4 by Ravikiran JanardhanaRavikiran J
 
05 junit
05 junit05 junit
05 junitmha4
 
Introduction To J unit
Introduction To J unitIntroduction To J unit
Introduction To J unitOlga Extone
 
JUnit 5 - The Next Generation
JUnit 5 - The Next GenerationJUnit 5 - The Next Generation
JUnit 5 - The Next GenerationKostadin Golev
 

Was ist angesagt? (20)

JUnit 5
JUnit 5JUnit 5
JUnit 5
 
Why Unit Testingl
Why Unit TestinglWhy Unit Testingl
Why Unit Testingl
 
Testing on Android
Testing on AndroidTesting on Android
Testing on Android
 
Test driven development - JUnit basics and best practices
Test driven development - JUnit basics and best practicesTest driven development - JUnit basics and best practices
Test driven development - JUnit basics and best practices
 
Renaissance of JUnit - Introduction to JUnit 5
Renaissance of JUnit - Introduction to JUnit 5Renaissance of JUnit - Introduction to JUnit 5
Renaissance of JUnit - Introduction to JUnit 5
 
JUNit Presentation
JUNit PresentationJUNit Presentation
JUNit Presentation
 
J Unit
J UnitJ Unit
J Unit
 
Open Source Test Workshop for QA Testers, Developers, IT Managers
Open Source Test Workshop for QA Testers, Developers, IT ManagersOpen Source Test Workshop for QA Testers, Developers, IT Managers
Open Source Test Workshop for QA Testers, Developers, IT Managers
 
Junit
JunitJunit
Junit
 
JUnit- A Unit Testing Framework
JUnit- A Unit Testing FrameworkJUnit- A Unit Testing Framework
JUnit- A Unit Testing Framework
 
Android testing part i
Android testing part iAndroid testing part i
Android testing part i
 
Unit Testing with JUnit4 by Ravikiran Janardhana
Unit Testing with JUnit4 by Ravikiran JanardhanaUnit Testing with JUnit4 by Ravikiran Janardhana
Unit Testing with JUnit4 by Ravikiran Janardhana
 
Junit
JunitJunit
Junit
 
JUnit Presentation
JUnit PresentationJUnit Presentation
JUnit Presentation
 
Junit 4.0
Junit 4.0Junit 4.0
Junit 4.0
 
05 junit
05 junit05 junit
05 junit
 
Testing with Junit4
Testing with Junit4Testing with Junit4
Testing with Junit4
 
Robotium - sampath
Robotium - sampathRobotium - sampath
Robotium - sampath
 
Introduction To J unit
Introduction To J unitIntroduction To J unit
Introduction To J unit
 
JUnit 5 - The Next Generation
JUnit 5 - The Next GenerationJUnit 5 - The Next Generation
JUnit 5 - The Next Generation
 

Andere mochten auch

Testing Android Application, Droidcon Torino
Testing Android Application, Droidcon TorinoTesting Android Application, Droidcon Torino
Testing Android Application, Droidcon TorinoPietro Alberto Rossi
 
Inside Android Testing
Inside Android TestingInside Android Testing
Inside Android TestingFernando Cejas
 
How to setup unit testing in Android Studio
How to setup unit testing in Android StudioHow to setup unit testing in Android Studio
How to setup unit testing in Android Studiotobiaspreuss
 
Developer testing 101: Become a Testing Fanatic
Developer testing 101: Become a Testing FanaticDeveloper testing 101: Become a Testing Fanatic
Developer testing 101: Become a Testing FanaticLB Denker
 
Introduction to android testing - oscon 2012
Introduction to android testing - oscon 2012Introduction to android testing - oscon 2012
Introduction to android testing - oscon 2012OSCON Byrum
 
Android Performance Tips & Tricks
Android Performance Tips & TricksAndroid Performance Tips & Tricks
Android Performance Tips & TricksSergii Zhuk
 
Unit Testing Android Applications
Unit Testing Android ApplicationsUnit Testing Android Applications
Unit Testing Android ApplicationsRody Middelkoop
 
Testing for Android: When, Where, and How to Successfully Use Test Automation
Testing for Android: When, Where, and How to Successfully Use Test AutomationTesting for Android: When, Where, and How to Successfully Use Test Automation
Testing for Android: When, Where, and How to Successfully Use Test AutomationTrent Peterson
 
Unit Testing on Android: why and how? DevFest Romania, Bucharest 2016
Unit Testing on Android: why and how? DevFest Romania, Bucharest 2016Unit Testing on Android: why and how? DevFest Romania, Bucharest 2016
Unit Testing on Android: why and how? DevFest Romania, Bucharest 2016Danny Preussler
 
Android Building, Testing and reversing
Android Building, Testing and reversingAndroid Building, Testing and reversing
Android Building, Testing and reversingEnrique López Mañas
 
Testing Android applications with Maveryx
Testing Android applications with MaveryxTesting Android applications with Maveryx
Testing Android applications with MaveryxMaveryx
 
Android Testing, Why So Hard?!
Android Testing, Why So Hard?!Android Testing, Why So Hard?!
Android Testing, Why So Hard?!Annyce Davis
 
Unit testing in android
Unit testing in androidUnit testing in android
Unit testing in androidLi-Wei Cheng
 
Unit testing on Android (Droidcon Dubai 2015)
Unit testing on Android (Droidcon Dubai 2015)Unit testing on Android (Droidcon Dubai 2015)
Unit testing on Android (Droidcon Dubai 2015)Danny Preussler
 
Unit testing and Android
Unit testing and AndroidUnit testing and Android
Unit testing and AndroidTomáš Kypta
 
Mobile Performance Testing - Best Practices
Mobile Performance Testing - Best PracticesMobile Performance Testing - Best Practices
Mobile Performance Testing - Best PracticesEran Kinsbrunner
 
Rapid Android Application Security Testing
Rapid Android Application Security TestingRapid Android Application Security Testing
Rapid Android Application Security TestingNutan Kumar Panda
 

Andere mochten auch (20)

Testing Android Application, Droidcon Torino
Testing Android Application, Droidcon TorinoTesting Android Application, Droidcon Torino
Testing Android Application, Droidcon Torino
 
Android testing
Android testingAndroid testing
Android testing
 
Inside Android Testing
Inside Android TestingInside Android Testing
Inside Android Testing
 
Testing With Open Source
Testing With Open SourceTesting With Open Source
Testing With Open Source
 
Introduction to android testing
Introduction to android testingIntroduction to android testing
Introduction to android testing
 
How to setup unit testing in Android Studio
How to setup unit testing in Android StudioHow to setup unit testing in Android Studio
How to setup unit testing in Android Studio
 
Developer testing 101: Become a Testing Fanatic
Developer testing 101: Become a Testing FanaticDeveloper testing 101: Become a Testing Fanatic
Developer testing 101: Become a Testing Fanatic
 
Introduction to android testing - oscon 2012
Introduction to android testing - oscon 2012Introduction to android testing - oscon 2012
Introduction to android testing - oscon 2012
 
Android Performance Tips & Tricks
Android Performance Tips & TricksAndroid Performance Tips & Tricks
Android Performance Tips & Tricks
 
Unit Testing Android Applications
Unit Testing Android ApplicationsUnit Testing Android Applications
Unit Testing Android Applications
 
Testing for Android: When, Where, and How to Successfully Use Test Automation
Testing for Android: When, Where, and How to Successfully Use Test AutomationTesting for Android: When, Where, and How to Successfully Use Test Automation
Testing for Android: When, Where, and How to Successfully Use Test Automation
 
Unit Testing on Android: why and how? DevFest Romania, Bucharest 2016
Unit Testing on Android: why and how? DevFest Romania, Bucharest 2016Unit Testing on Android: why and how? DevFest Romania, Bucharest 2016
Unit Testing on Android: why and how? DevFest Romania, Bucharest 2016
 
Android Building, Testing and reversing
Android Building, Testing and reversingAndroid Building, Testing and reversing
Android Building, Testing and reversing
 
Testing Android applications with Maveryx
Testing Android applications with MaveryxTesting Android applications with Maveryx
Testing Android applications with Maveryx
 
Android Testing, Why So Hard?!
Android Testing, Why So Hard?!Android Testing, Why So Hard?!
Android Testing, Why So Hard?!
 
Unit testing in android
Unit testing in androidUnit testing in android
Unit testing in android
 
Unit testing on Android (Droidcon Dubai 2015)
Unit testing on Android (Droidcon Dubai 2015)Unit testing on Android (Droidcon Dubai 2015)
Unit testing on Android (Droidcon Dubai 2015)
 
Unit testing and Android
Unit testing and AndroidUnit testing and Android
Unit testing and Android
 
Mobile Performance Testing - Best Practices
Mobile Performance Testing - Best PracticesMobile Performance Testing - Best Practices
Mobile Performance Testing - Best Practices
 
Rapid Android Application Security Testing
Rapid Android Application Security TestingRapid Android Application Security Testing
Rapid Android Application Security Testing
 

Ähnlich wie Testing Android

Guide to the jungle of testing frameworks
Guide to the jungle of testing frameworksGuide to the jungle of testing frameworks
Guide to the jungle of testing frameworksTomáš Kypta
 
An Introduction To Unit Testing and TDD
An Introduction To Unit Testing and TDDAn Introduction To Unit Testing and TDD
An Introduction To Unit Testing and TDDAhmed Ehab AbdulAziz
 
Xp Day 080506 Unit Tests And Mocks
Xp Day 080506 Unit Tests And MocksXp Day 080506 Unit Tests And Mocks
Xp Day 080506 Unit Tests And Mocksguillaumecarre
 
Junit4&testng presentation
Junit4&testng presentationJunit4&testng presentation
Junit4&testng presentationSanjib Dhar
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven DevelopmentJohn Blum
 
Grails 1.1 Testing - Unit, Integration & Functional
Grails 1.1 Testing - Unit, Integration & FunctionalGrails 1.1 Testing - Unit, Integration & Functional
Grails 1.1 Testing - Unit, Integration & Functional2Paths Solutions Ltd.
 
Junit and cactus
Junit and cactusJunit and cactus
Junit and cactusHimanshu
 
J unit presentation
J unit presentationJ unit presentation
J unit presentationPriya Sharma
 
Unit Testing Using Mockito in Android (1).pdf
Unit Testing Using Mockito in Android (1).pdfUnit Testing Using Mockito in Android (1).pdf
Unit Testing Using Mockito in Android (1).pdfKaty Slemon
 
Unit Testing on Android - Droidcon Berlin 2015
Unit Testing on Android - Droidcon Berlin 2015Unit Testing on Android - Droidcon Berlin 2015
Unit Testing on Android - Droidcon Berlin 2015Buşra Deniz, CSM
 
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
 
Jack borden jb471909_junit1
Jack borden jb471909_junit1Jack borden jb471909_junit1
Jack borden jb471909_junit1jborden33
 
Jack borden jb471909_junit
Jack borden jb471909_junitJack borden jb471909_junit
Jack borden jb471909_junitjborden33
 

Ähnlich wie Testing Android (20)

Guide to the jungle of testing frameworks
Guide to the jungle of testing frameworksGuide to the jungle of testing frameworks
Guide to the jungle of testing frameworks
 
An Introduction To Unit Testing and TDD
An Introduction To Unit Testing and TDDAn Introduction To Unit Testing and TDD
An Introduction To Unit Testing and TDD
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Xp Day 080506 Unit Tests And Mocks
Xp Day 080506 Unit Tests And MocksXp Day 080506 Unit Tests And Mocks
Xp Day 080506 Unit Tests And Mocks
 
Unit testing_pps
Unit testing_ppsUnit testing_pps
Unit testing_pps
 
Junit4&testng presentation
Junit4&testng presentationJunit4&testng presentation
Junit4&testng presentation
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven Development
 
Grails 1.1 Testing - Unit, Integration & Functional
Grails 1.1 Testing - Unit, Integration & FunctionalGrails 1.1 Testing - Unit, Integration & Functional
Grails 1.1 Testing - Unit, Integration & Functional
 
Junit and cactus
Junit and cactusJunit and cactus
Junit and cactus
 
Unit Testing in Java
Unit Testing in JavaUnit Testing in Java
Unit Testing in Java
 
J unit presentation
J unit presentationJ unit presentation
J unit presentation
 
Testing Tools
Testing ToolsTesting Tools
Testing Tools
 
Unit Testing Using Mockito in Android (1).pdf
Unit Testing Using Mockito in Android (1).pdfUnit Testing Using Mockito in Android (1).pdf
Unit Testing Using Mockito in Android (1).pdf
 
Unit Testing on Android - Droidcon Berlin 2015
Unit Testing on Android - Droidcon Berlin 2015Unit Testing on Android - Droidcon Berlin 2015
Unit Testing on Android - Droidcon Berlin 2015
 
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)
 
8-testing.pptx
8-testing.pptx8-testing.pptx
8-testing.pptx
 
Jack borden jb471909_junit1
Jack borden jb471909_junit1Jack borden jb471909_junit1
Jack borden jb471909_junit1
 
Jack borden jb471909_junit
Jack borden jb471909_junitJack borden jb471909_junit
Jack borden jb471909_junit
 
JMockit
JMockitJMockit
JMockit
 
WindowTester PRO
WindowTester PROWindowTester PRO
WindowTester PRO
 

Kürzlich hochgeladen

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FMESafe Software
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...apidays
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native ApplicationsWSO2
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxRustici Software
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWERMadyBayot
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesrafiqahmad00786416
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Angeliki Cooney
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistandanishmna97
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...apidays
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Bhuvaneswari Subramani
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelDeepika Singh
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxRemote DBA Services
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 

Kürzlich hochgeladen (20)

Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
Apidays New York 2024 - APIs in 2030: The Risk of Technological Sleepwalk by ...
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
Corporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptxCorporate and higher education May webinar.pptx
Corporate and higher education May webinar.pptx
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWEREMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
EMPOWERMENT TECHNOLOGY GRADE 11 QUARTER 2 REVIEWER
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
ICT role in 21st century education and its challenges
ICT role in 21st century education and its challengesICT role in 21st century education and its challenges
ICT role in 21st century education and its challenges
 
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
Biography Of Angeliki Cooney | Senior Vice President Life Sciences | Albany, ...
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...Apidays New York 2024 - The value of a flexible API Management solution for O...
Apidays New York 2024 - The value of a flexible API Management solution for O...
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot ModelMcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
Mcleodganj Call Girls 🥰 8617370543 Service Offer VIP Hot Model
 
Vector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptxVector Search -An Introduction in Oracle Database 23ai.pptx
Vector Search -An Introduction in Oracle Database 23ai.pptx
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 

Testing Android

  • 1. TESTING ANDROID Marc Chung OpenRain marc.chung@openrain.com Friday, August 28, 2009 1
  • 2. Agenda Introduce Android testing concepts Unit and mock testing + Demos Android testing overview + Demos Q&A Friday, August 28, 2009 2
  • 3. Unit testing in Java JUnit is the most popular framework Most projects, frameworks, IDEs will ship with support Out of the box, Eclipse IDE has good JUnit support There are many frameworks http://en.wikipedia.org/wiki/List_of_unit_testing_frameworks#Java Friday, August 28, 2009 3
  • 4. Unit testing demo Twitter Demo Uses JUnit Login/password Update status Friday, August 28, 2009 4
  • 5. public void testStatusUpdate() { try { IMyTwitter twitter = new MyTwitter("supertesting", "s3!kretep@s5"); TwitterClient client = new TwitterClient(twitter); String update = "Hello Phoenix Android"; client.post(update); Assert.assertEquals(update, client.getLatestPost()); } catch (TwitterException te) { Assert.fail("Shouldn't see this because the credentials are correct"); } } Friday, August 28, 2009 5
  • 6. Mock Objects in Java A Mock is “fake” object which mimics real objects for the purpose of testing Mimics real objects for testing Such as a web service request Mocking is a style of testing http://martinfowler.com/articles/mocksArentStubs.html Friday, August 28, 2009 6
  • 7. Mock testing demo Twitter Demo Uses EasyMock Avoid issuing live requests Friday, August 28, 2009 7
  • 8. public void testStatusUpdate() { String updateStatus = "Hello Phoenix Android"; IMyTwitter mockedTwitter = EasyMock.createMock(IMyTwitter.class); expect(mockedTwitter.getStatus()).andReturn(null); expect(mockedTwitter.updateStatus(updateStatus)).andReturn(null); replay(mockedTwitter); TwitterClient client = new TwitterClient(mockedTwitter); client.post(updateStatus); Assert.assertEquals(updateStatus, client.getLatestPost()); verify(mockedTwitter); } Friday, August 28, 2009 8
  • 9. Android Testing Testing Android requires JUnit Write tests to run and test parts of your application InstrumentationTestRunner runs your test as an application Executes code on emulator Friday, August 28, 2009 9
  • 10. Setting up your project Using the command line tool will create a tests/ directory inside the project. android create project -t 3 -n hello_world -p hello_world -a HelloWorld -k com.openrain.hello_world Use Eclipse manually. Doesn’t create a tests/ directory Manually create two projects. Friday, August 28, 2009 10
  • 11. Running Android tests Two ways to run your tests Command line runner Eclipse runner Friday, August 28, 2009 11
  • 12. AndroidTestCase unit testing faster and easier to boot strap only have access to a Context useful for asserting layout, position, and components Friday, August 28, 2009 12
  • 13. ActivityInstrumentationTestCase functional unit testing access to a real live Activity instance may simulate key events slower Friday, August 28, 2009 13
  • 14. Instrumentation Demo Functional tests Test drives the Activity Friday, August 28, 2009 14
  • 15. Other Android tests ServiceTestCase For testing services ActivityUnitTestCase and ActivityTestCase For testing an Activity in isolation ApplicationTestCase Full integration testing Friday, August 28, 2009 15
  • 16. More Android testing Testing APIs http://developer.android.com/reference/android/test/package-summary.html android.test android.test.mock Friday, August 28, 2009 16
  • 17. Tips Isolate and test non-Android code separately. Functional tests use live objects. Slow, but reliable. Javadoc is your friend Friday, August 28, 2009 17
  • 18. Future topics Code coverage tools Continuous integration tools Performance testing Friday, August 28, 2009 18
  • 19. Thank you Join Phoenix Android Mailing list http://phoenixandroid.com Follow me on Twitter: @heisenthought Friday, August 28, 2009 19