SlideShare une entreprise Scribd logo
1  sur  19
Télécharger pour lire hors ligne
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

Contenu connexe

Tendances

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
 

Tendances (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
 

En vedette

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
 

En vedette (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
 

Similaire à 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
 

Similaire à 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
 

Dernier

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
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘RTylerCroy
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfEnterprise Knowledge
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024The Digital Insurer
 
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
 
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
 
[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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsJoaquim Jorge
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationSafe Software
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Servicegiselly40
 
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
 
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
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityPrincipled Technologies
 
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
 
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
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessPixlogix Infotech
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
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
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsMaria Levchenko
 

Dernier (20)

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
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
🐬 The future of MySQL is Postgres 🐘
🐬  The future of MySQL is Postgres   🐘🐬  The future of MySQL is Postgres   🐘
🐬 The future of MySQL is Postgres 🐘
 
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdfThe Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
The Role of Taxonomy and Ontology in Semantic Layers - Heather Hedden.pdf
 
Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024Tata AIG General Insurance Company - Insurer Innovation Award 2024
Tata AIG General Insurance Company - Insurer Innovation Award 2024
 
Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 2024Finology Group – Insurtech Innovation Award 2024
Finology Group – Insurtech Innovation Award 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
 
[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
 
Artificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and MythsArtificial Intelligence: Facts and Myths
Artificial Intelligence: Facts and Myths
 
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time AutomationFrom Event to Action: Accelerate Your Decision Making with Real-Time Automation
From Event to Action: Accelerate Your Decision Making with Real-Time Automation
 
CNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of ServiceCNv6 Instructor Chapter 6 Quality of Service
CNv6 Instructor Chapter 6 Quality of Service
 
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
 
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
 
Boost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivityBoost PC performance: How more available memory can improve productivity
Boost PC performance: How more available memory can improve productivity
 
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
 
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
 
Advantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your BusinessAdvantages of Hiring UIUX Design Service Providers for Your Business
Advantages of Hiring UIUX Design Service Providers for Your Business
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
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
 
Handwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed textsHandwritten Text Recognition for manuscripts and early printed texts
Handwritten Text Recognition for manuscripts and early printed texts
 

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