SlideShare ist ein Scribd-Unternehmen logo
1 von 44
Downloaden Sie, um offline zu lesen
Gilang Ramadhan
Academy Content Writer Dicoding
Associate Android Developer
Play with Testing on Android
Play with
Testing?
Specifications of the
application
Write the codes
Test the application manually
New Feature,
New Bugs...
How to get started?
⬅, ➡,
L1, L2, R1, R2,
⬆, ⬇, ⬅, ➡
Android
Jetpack
Source : Android Jetpack
Follow best practices
Built around modern design practices, Android Jetpack
Libraries enable fewer crashes and less memory leaks with
backwards-compatibility baked in.
Eliminate boilerplate code
Android Jetpack manages tedious activities like background
tasks, navigation, and lifecycle management, so you can focus
on what makes your app great.
Reduce fragmentation
Reduce complexity with libraries that work consistently across
Android versions and devices.
Why use Android Jetpack?
Test
Speed Scope Fidelity
Speed
Scope
Fidelity
#of test
Testing Terminology
“The percentage of your
code that is executed by
your tests”
Test Coverage
Test Coverage
Test Driven Development
The two cycles associated with iterative, test-driven development
Source : Fundamentals of Testing
is an application development method developed by
testing.
● Writing Tests
● Running Tests
● Write down the Code
● Running Tests
● Refactor Code
Test Driven Development
● More Productive
● Code is neater Safer
● Refactoring
● Minimizing Bug
● Documentation
Advantages of using TDD
Test Doubles
● Do not mock types you don’t own
● Don’t mock value objects
● Don’t mock everything
● Show love with your tests!
Test Doubles
Given, When, Then
“Arrange, Act,
Assert”
Example
Architecture Pattern
REPLACE ME
The important features of a testable architecture are:
● Each class should have a clearly
defined purpose.
● Limit and be explicit about which
classes know about other classes.
● Use constructor injection.
● Keep Android code out of the view
model.
Architecture Pattern
1. Local unit tests
Located at module-name/src/test/java/.
2. Instrumented tests
Located at module-name/src/androidTest/java/.
1. Run Toolbar.
2. Testing Toolbar.
3. Context Menu.
4. Test Status Icon.
5. Jump to Code.
Unit Test
Instrumented Test
Let’s Try Together
Source:
● Advanced Android in Kotlin 05.1: Testing
Basics Updated
● Advanced Android in Kotlin 05.2:
Introduction to Test Doubles and
Dependency Injection
● Advanced Android in Kotlin 05.3: Survey of
Testing Topics
What we've covered:
● How to run tests from Android Studio.
● The difference between local (test) and
instrumentation tests (androidTest).
● How to write local unit tests using JUnit and
Hamcrest.
● Setting up ViewModel tests with the AndroidX Test
Library.
Testing Basics Updated
What we've covered:
● What you want to test and your testing strategy determine the kinds of test you are
going to implement for your app. Unit tests are focused and fast. Integration
tests verify interaction between parts of your program. End-to-end tests verify
features, have the highest fidelity, are often instrumented, and may take longer to
run.
● The architecture of your app influences how hard it is to test.
● To isolate parts of your app for testing, you can use test doubles. A test double is a
version of a class crafted specifically for testing. For example, you fake getting
data from a database or the internet.
● Use dependency injection to replace a real class with a testing class, for example,
a repository or a networking layer.
● Use instrumented testing (androidTest) to launch UI components.
● When you can't use constructor dependency injection, for example to launch a
fragment, you can often use a service locator. The Service Locator pattern is an
alternative to Dependency Injection. It involves creating a singleton class called
the "Service Locator", whose purpose is to provide dependencies, both for the
regular and test code.
Introduction to Test Doubles
and Dependency Injection
What we've covered:
● A review of testing coroutines from previous lessons, including
covering the usage of runBlocking versus runBlockingTest.
● How to test coroutines that use viewModelScope by using
TestCoroutineDispatcher
● TestCoroutineDispatcher's ability to pauseDispatcher and
resumeDispatcher to control coroutine execution
● Testing error handling by updating a fake
● Testing your data layer, including your DAO and local data source
● Using IdlingResource (and the CountingIldingResource subclass)
to write end to end tests that both include long running code and
work with the data binding library.
● Testing global app navigation in an end to end test.
Survey of Testing Topics
Advantages of Testing
Testing also provides you with the following
advantages:
● Rapid feedback on failures.
● Early failure detection in the
development cycle.
● Safer code refactoring, letting you
optimize code without worrying about
regressions.
● Stable development velocity, helping
you minimize technical debt.
“Code without tests is bad code”
Michael Feathers, Working Effectively with Legacy Code
REPLACE ME
Belajar Android
Jetpack PRO
Contact:
gilang@dicoding.com
www.dicoding.com
Follow us: @dicoding
Credit:
Unsplash
Google
Pexels

Weitere ähnliche Inhalte

Was ist angesagt?

What Is Cucumber?
What Is Cucumber?What Is Cucumber?
What Is Cucumber?QATestLab
 
Code review process with JetBrains UpSource
Code review process with JetBrains UpSourceCode review process with JetBrains UpSource
Code review process with JetBrains UpSourceOleksii Prohonnyi
 
Continous integration
Continous integrationContinous integration
Continous integrationJeremy Wilken
 
Efficient mobile automation
Efficient mobile automationEfficient mobile automation
Efficient mobile automationVitaly Tatarinov
 
Code Review Tool Evaluation
Code Review Tool EvaluationCode Review Tool Evaluation
Code Review Tool EvaluationKate Semizhon
 
Code Review
Code ReviewCode Review
Code ReviewTu Hoang
 
Continous Integration: A Case Study
Continous Integration: A Case StudyContinous Integration: A Case Study
Continous Integration: A Case StudyTalentica Software
 
Robot framework - SAST Väst Q3
Robot framework - SAST Väst Q3Robot framework - SAST Väst Q3
Robot framework - SAST Väst Q3Anders Arnholm
 
Choosing the Best Open Source Test Automation Tool for You
Choosing the Best Open Source Test Automation Tool for YouChoosing the Best Open Source Test Automation Tool for You
Choosing the Best Open Source Test Automation Tool for YouPerfecto by Perforce
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven DevelopmentJohn Blanco
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven DevelopmentEffective
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven DevelopmentEffectiveUI
 
Elements of a Test Framework
Elements of a Test FrameworkElements of a Test Framework
Elements of a Test FrameworkSmartBear
 
Quality Built In @ Spotify
Quality Built In @ SpotifyQuality Built In @ Spotify
Quality Built In @ SpotifyAndrii Dzynia
 
Test driven development_continuous_integration
Test driven development_continuous_integrationTest driven development_continuous_integration
Test driven development_continuous_integrationhaochenglee
 
Beyond Unit Testing
Beyond Unit TestingBeyond Unit Testing
Beyond Unit TestingSøren Lund
 

Was ist angesagt? (18)

What Is Cucumber?
What Is Cucumber?What Is Cucumber?
What Is Cucumber?
 
Code review process with JetBrains UpSource
Code review process with JetBrains UpSourceCode review process with JetBrains UpSource
Code review process with JetBrains UpSource
 
Continous integration
Continous integrationContinous integration
Continous integration
 
Efficient mobile automation
Efficient mobile automationEfficient mobile automation
Efficient mobile automation
 
Code Review Tool Evaluation
Code Review Tool EvaluationCode Review Tool Evaluation
Code Review Tool Evaluation
 
Code Review
Code ReviewCode Review
Code Review
 
Continous Integration: A Case Study
Continous Integration: A Case StudyContinous Integration: A Case Study
Continous Integration: A Case Study
 
Robot framework - SAST Väst Q3
Robot framework - SAST Väst Q3Robot framework - SAST Väst Q3
Robot framework - SAST Väst Q3
 
Choosing the Best Open Source Test Automation Tool for You
Choosing the Best Open Source Test Automation Tool for YouChoosing the Best Open Source Test Automation Tool for You
Choosing the Best Open Source Test Automation Tool for You
 
BDD with Cucumber
BDD with CucumberBDD with Cucumber
BDD with Cucumber
 
Test Driven Development
Test Driven DevelopmentTest Driven Development
Test Driven Development
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven Development
 
Test-Driven Development
Test-Driven DevelopmentTest-Driven Development
Test-Driven Development
 
Elements of a Test Framework
Elements of a Test FrameworkElements of a Test Framework
Elements of a Test Framework
 
Quality Built In @ Spotify
Quality Built In @ SpotifyQuality Built In @ Spotify
Quality Built In @ Spotify
 
Test driven development_continuous_integration
Test driven development_continuous_integrationTest driven development_continuous_integration
Test driven development_continuous_integration
 
Test automation within a scrum process
Test automation within a scrum processTest automation within a scrum process
Test automation within a scrum process
 
Beyond Unit Testing
Beyond Unit TestingBeyond Unit Testing
Beyond Unit Testing
 

Ähnlich wie Play with Testing on Android - Gilang Ramadhan (Academy Content Writer at Dicoding)

Testing on Android
Testing on AndroidTesting on Android
Testing on AndroidAri Lacenski
 
Client Side Unit Testing
Client Side Unit TestingClient Side Unit Testing
Client Side Unit Testingcloud chen
 
Innovation Generation - The Mobile Meetup: Android Best Practices
Innovation Generation - The Mobile Meetup: Android Best PracticesInnovation Generation - The Mobile Meetup: Android Best Practices
Innovation Generation - The Mobile Meetup: Android Best PracticesSolstice Mobile Argentina
 
Getting started with appium
Getting started with appiumGetting started with appium
Getting started with appiumPratik Patel
 
End-end tests as first class citizens - SeleniumConf 2020
End-end tests as first class citizens - SeleniumConf 2020End-end tests as first class citizens - SeleniumConf 2020
End-end tests as first class citizens - SeleniumConf 2020Abhijeet Vaikar
 
Dive into Angular, part 5: Experience
Dive into Angular, part 5: ExperienceDive into Angular, part 5: Experience
Dive into Angular, part 5: ExperienceOleksii Prohonnyi
 
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosUnit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosFlutter Agency
 
Developer Experience to Testing
Developer Experience to TestingDeveloper Experience to Testing
Developer Experience to TestingMozaic Works
 
ATAGTR2017 Protractor Cucumber BDD Approach
ATAGTR2017 Protractor Cucumber BDD ApproachATAGTR2017 Protractor Cucumber BDD Approach
ATAGTR2017 Protractor Cucumber BDD ApproachAgile Testing Alliance
 
Testing of React JS app
Testing of React JS appTesting of React JS app
Testing of React JS appAleks Zinevych
 
Binary Studio Academy: .NET Code Testing
Binary Studio Academy: .NET Code TestingBinary Studio Academy: .NET Code Testing
Binary Studio Academy: .NET Code TestingBinary Studio
 
Enhancing Website and Application Testing with Java Scrapers.pdf
Enhancing Website and Application Testing with Java Scrapers.pdfEnhancing Website and Application Testing with Java Scrapers.pdf
Enhancing Website and Application Testing with Java Scrapers.pdfAnanthReddy38
 
Behavior Driven Development by Example
Behavior Driven Development by ExampleBehavior Driven Development by Example
Behavior Driven Development by ExampleNalin Goonawardana
 
Katalon Studio - Successful Test Automation for both Testers and Developers
Katalon Studio - Successful Test Automation for both Testers and DevelopersKatalon Studio - Successful Test Automation for both Testers and Developers
Katalon Studio - Successful Test Automation for both Testers and DevelopersKatalon Studio
 
Software Testing Basic Concepts
Software Testing Basic ConceptsSoftware Testing Basic Concepts
Software Testing Basic Conceptswesovi
 
Unit Testing in Angular
Unit Testing in AngularUnit Testing in Angular
Unit Testing in AngularKnoldus Inc.
 

Ähnlich wie Play with Testing on Android - Gilang Ramadhan (Academy Content Writer at Dicoding) (20)

Testing on Android
Testing on AndroidTesting on Android
Testing on Android
 
Client Side Unit Testing
Client Side Unit TestingClient Side Unit Testing
Client Side Unit Testing
 
Innovation Generation - The Mobile Meetup: Android Best Practices
Innovation Generation - The Mobile Meetup: Android Best PracticesInnovation Generation - The Mobile Meetup: Android Best Practices
Innovation Generation - The Mobile Meetup: Android Best Practices
 
Testing Angular
Testing AngularTesting Angular
Testing Angular
 
Getting started with appium
Getting started with appiumGetting started with appium
Getting started with appium
 
Unit testing (eng)
Unit testing (eng)Unit testing (eng)
Unit testing (eng)
 
End-end tests as first class citizens - SeleniumConf 2020
End-end tests as first class citizens - SeleniumConf 2020End-end tests as first class citizens - SeleniumConf 2020
End-end tests as first class citizens - SeleniumConf 2020
 
Dive into Angular, part 5: Experience
Dive into Angular, part 5: ExperienceDive into Angular, part 5: Experience
Dive into Angular, part 5: Experience
 
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex ScenariosUnit Testing in Flutter - From Workflow Essentials to Complex Scenarios
Unit Testing in Flutter - From Workflow Essentials to Complex Scenarios
 
NET Code Testing
NET Code TestingNET Code Testing
NET Code Testing
 
Developer Experience to Testing
Developer Experience to TestingDeveloper Experience to Testing
Developer Experience to Testing
 
ATAGTR2017 Protractor Cucumber BDD Approach
ATAGTR2017 Protractor Cucumber BDD ApproachATAGTR2017 Protractor Cucumber BDD Approach
ATAGTR2017 Protractor Cucumber BDD Approach
 
Testing of React JS app
Testing of React JS appTesting of React JS app
Testing of React JS app
 
Mohseen Ali
Mohseen AliMohseen Ali
Mohseen Ali
 
Binary Studio Academy: .NET Code Testing
Binary Studio Academy: .NET Code TestingBinary Studio Academy: .NET Code Testing
Binary Studio Academy: .NET Code Testing
 
Enhancing Website and Application Testing with Java Scrapers.pdf
Enhancing Website and Application Testing with Java Scrapers.pdfEnhancing Website and Application Testing with Java Scrapers.pdf
Enhancing Website and Application Testing with Java Scrapers.pdf
 
Behavior Driven Development by Example
Behavior Driven Development by ExampleBehavior Driven Development by Example
Behavior Driven Development by Example
 
Katalon Studio - Successful Test Automation for both Testers and Developers
Katalon Studio - Successful Test Automation for both Testers and DevelopersKatalon Studio - Successful Test Automation for both Testers and Developers
Katalon Studio - Successful Test Automation for both Testers and Developers
 
Software Testing Basic Concepts
Software Testing Basic ConceptsSoftware Testing Basic Concepts
Software Testing Basic Concepts
 
Unit Testing in Angular
Unit Testing in AngularUnit Testing in Angular
Unit Testing in Angular
 

Mehr von DicodingEvent

Developer Coaching #114.pdf
Developer Coaching #114.pdfDeveloper Coaching #114.pdf
Developer Coaching #114.pdfDicodingEvent
 
Ask Us Anything about Studi Independen Bersertifikat Kampus Merdeka X Dicodin...
Ask Us Anything about Studi Independen Bersertifikat Kampus Merdeka X Dicodin...Ask Us Anything about Studi Independen Bersertifikat Kampus Merdeka X Dicodin...
Ask Us Anything about Studi Independen Bersertifikat Kampus Merdeka X Dicodin...DicodingEvent
 
tantangan menjadi developer di abad 21
tantangan menjadi developer di abad 21tantangan menjadi developer di abad 21
tantangan menjadi developer di abad 21DicodingEvent
 
Mengenalkan augmented reality (ar) pada snapchat
Mengenalkan augmented reality (ar) pada snapchatMengenalkan augmented reality (ar) pada snapchat
Mengenalkan augmented reality (ar) pada snapchatDicodingEvent
 
Membangun Aplikasi Serverless di Platfrom AWS
Membangun Aplikasi Serverless di Platfrom AWSMembangun Aplikasi Serverless di Platfrom AWS
Membangun Aplikasi Serverless di Platfrom AWSDicodingEvent
 
IDCamp X Madrasah: Pengenalan Computational Thinking
IDCamp X Madrasah: Pengenalan Computational ThinkingIDCamp X Madrasah: Pengenalan Computational Thinking
IDCamp X Madrasah: Pengenalan Computational ThinkingDicodingEvent
 
Membuat Produk Digital Terbaik ala Startup Unicorn
Membuat Produk Digital Terbaik ala Startup UnicornMembuat Produk Digital Terbaik ala Startup Unicorn
Membuat Produk Digital Terbaik ala Startup UnicornDicodingEvent
 
TechTalk 2021: Peran IT Security dalam Penerapan DevOps
TechTalk 2021: Peran IT Security dalam Penerapan DevOpsTechTalk 2021: Peran IT Security dalam Penerapan DevOps
TechTalk 2021: Peran IT Security dalam Penerapan DevOpsDicodingEvent
 
TechTalk 2021: Peningkatan Performa Software Delivery dengan CI/CD
TechTalk 2021: Peningkatan Performa Software Delivery dengan CI/CDTechTalk 2021: Peningkatan Performa Software Delivery dengan CI/CD
TechTalk 2021: Peningkatan Performa Software Delivery dengan CI/CDDicodingEvent
 
Membuat Solusi Bermanfaat dengan Programming - Nur Rohman
Membuat Solusi Bermanfaat dengan Programming - Nur RohmanMembuat Solusi Bermanfaat dengan Programming - Nur Rohman
Membuat Solusi Bermanfaat dengan Programming - Nur RohmanDicodingEvent
 
Potensi karier menjadi ios developer di masa depan
Potensi karier menjadi ios developer di masa depanPotensi karier menjadi ios developer di masa depan
Potensi karier menjadi ios developer di masa depanDicodingEvent
 
Id camp x dicoding live : persiapan jadi software engineer hebat 101
Id camp x dicoding live : persiapan jadi software engineer hebat 101Id camp x dicoding live : persiapan jadi software engineer hebat 101
Id camp x dicoding live : persiapan jadi software engineer hebat 101DicodingEvent
 
Tips sukses berkarir sebagai developer dan programmer 2021
Tips sukses berkarir sebagai developer dan programmer 2021Tips sukses berkarir sebagai developer dan programmer 2021
Tips sukses berkarir sebagai developer dan programmer 2021DicodingEvent
 
Teknologi Baru Android di Google I/O 2021 - Andrew Kurniadi
Teknologi Baru Android di Google I/O 2021 - Andrew KurniadiTeknologi Baru Android di Google I/O 2021 - Andrew Kurniadi
Teknologi Baru Android di Google I/O 2021 - Andrew KurniadiDicodingEvent
 
Dicoding Developer Coaching #38: Android | 5 Library Android yang Patut Kamu ...
Dicoding Developer Coaching #38: Android | 5 Library Android yang Patut Kamu ...Dicoding Developer Coaching #38: Android | 5 Library Android yang Patut Kamu ...
Dicoding Developer Coaching #38: Android | 5 Library Android yang Patut Kamu ...DicodingEvent
 
Dicoding Developer Coaching #37: Android | Kesalahan yang Sering Terjadi pada...
Dicoding Developer Coaching #37: Android | Kesalahan yang Sering Terjadi pada...Dicoding Developer Coaching #37: Android | Kesalahan yang Sering Terjadi pada...
Dicoding Developer Coaching #37: Android | Kesalahan yang Sering Terjadi pada...DicodingEvent
 
Pengantar Cloud Computing dengan AWS - Petra Novandi Barus
Pengantar Cloud Computing dengan AWS - Petra Novandi BarusPengantar Cloud Computing dengan AWS - Petra Novandi Barus
Pengantar Cloud Computing dengan AWS - Petra Novandi BarusDicodingEvent
 
Dicoding Developer Coaching #36: Android | Pentingnya Performa pada Aplikasi ...
Dicoding Developer Coaching #36: Android | Pentingnya Performa pada Aplikasi ...Dicoding Developer Coaching #36: Android | Pentingnya Performa pada Aplikasi ...
Dicoding Developer Coaching #36: Android | Pentingnya Performa pada Aplikasi ...DicodingEvent
 
Dicoding Developer Coaching #34: Android | Modular Android App dengan Dynamic...
Dicoding Developer Coaching #34: Android | Modular Android App dengan Dynamic...Dicoding Developer Coaching #34: Android | Modular Android App dengan Dynamic...
Dicoding Developer Coaching #34: Android | Modular Android App dengan Dynamic...DicodingEvent
 
Dicoding Developer Coaching #35: Android | Setup Continuous Integration di An...
Dicoding Developer Coaching #35: Android | Setup Continuous Integration di An...Dicoding Developer Coaching #35: Android | Setup Continuous Integration di An...
Dicoding Developer Coaching #35: Android | Setup Continuous Integration di An...DicodingEvent
 

Mehr von DicodingEvent (20)

Developer Coaching #114.pdf
Developer Coaching #114.pdfDeveloper Coaching #114.pdf
Developer Coaching #114.pdf
 
Ask Us Anything about Studi Independen Bersertifikat Kampus Merdeka X Dicodin...
Ask Us Anything about Studi Independen Bersertifikat Kampus Merdeka X Dicodin...Ask Us Anything about Studi Independen Bersertifikat Kampus Merdeka X Dicodin...
Ask Us Anything about Studi Independen Bersertifikat Kampus Merdeka X Dicodin...
 
tantangan menjadi developer di abad 21
tantangan menjadi developer di abad 21tantangan menjadi developer di abad 21
tantangan menjadi developer di abad 21
 
Mengenalkan augmented reality (ar) pada snapchat
Mengenalkan augmented reality (ar) pada snapchatMengenalkan augmented reality (ar) pada snapchat
Mengenalkan augmented reality (ar) pada snapchat
 
Membangun Aplikasi Serverless di Platfrom AWS
Membangun Aplikasi Serverless di Platfrom AWSMembangun Aplikasi Serverless di Platfrom AWS
Membangun Aplikasi Serverless di Platfrom AWS
 
IDCamp X Madrasah: Pengenalan Computational Thinking
IDCamp X Madrasah: Pengenalan Computational ThinkingIDCamp X Madrasah: Pengenalan Computational Thinking
IDCamp X Madrasah: Pengenalan Computational Thinking
 
Membuat Produk Digital Terbaik ala Startup Unicorn
Membuat Produk Digital Terbaik ala Startup UnicornMembuat Produk Digital Terbaik ala Startup Unicorn
Membuat Produk Digital Terbaik ala Startup Unicorn
 
TechTalk 2021: Peran IT Security dalam Penerapan DevOps
TechTalk 2021: Peran IT Security dalam Penerapan DevOpsTechTalk 2021: Peran IT Security dalam Penerapan DevOps
TechTalk 2021: Peran IT Security dalam Penerapan DevOps
 
TechTalk 2021: Peningkatan Performa Software Delivery dengan CI/CD
TechTalk 2021: Peningkatan Performa Software Delivery dengan CI/CDTechTalk 2021: Peningkatan Performa Software Delivery dengan CI/CD
TechTalk 2021: Peningkatan Performa Software Delivery dengan CI/CD
 
Membuat Solusi Bermanfaat dengan Programming - Nur Rohman
Membuat Solusi Bermanfaat dengan Programming - Nur RohmanMembuat Solusi Bermanfaat dengan Programming - Nur Rohman
Membuat Solusi Bermanfaat dengan Programming - Nur Rohman
 
Potensi karier menjadi ios developer di masa depan
Potensi karier menjadi ios developer di masa depanPotensi karier menjadi ios developer di masa depan
Potensi karier menjadi ios developer di masa depan
 
Id camp x dicoding live : persiapan jadi software engineer hebat 101
Id camp x dicoding live : persiapan jadi software engineer hebat 101Id camp x dicoding live : persiapan jadi software engineer hebat 101
Id camp x dicoding live : persiapan jadi software engineer hebat 101
 
Tips sukses berkarir sebagai developer dan programmer 2021
Tips sukses berkarir sebagai developer dan programmer 2021Tips sukses berkarir sebagai developer dan programmer 2021
Tips sukses berkarir sebagai developer dan programmer 2021
 
Teknologi Baru Android di Google I/O 2021 - Andrew Kurniadi
Teknologi Baru Android di Google I/O 2021 - Andrew KurniadiTeknologi Baru Android di Google I/O 2021 - Andrew Kurniadi
Teknologi Baru Android di Google I/O 2021 - Andrew Kurniadi
 
Dicoding Developer Coaching #38: Android | 5 Library Android yang Patut Kamu ...
Dicoding Developer Coaching #38: Android | 5 Library Android yang Patut Kamu ...Dicoding Developer Coaching #38: Android | 5 Library Android yang Patut Kamu ...
Dicoding Developer Coaching #38: Android | 5 Library Android yang Patut Kamu ...
 
Dicoding Developer Coaching #37: Android | Kesalahan yang Sering Terjadi pada...
Dicoding Developer Coaching #37: Android | Kesalahan yang Sering Terjadi pada...Dicoding Developer Coaching #37: Android | Kesalahan yang Sering Terjadi pada...
Dicoding Developer Coaching #37: Android | Kesalahan yang Sering Terjadi pada...
 
Pengantar Cloud Computing dengan AWS - Petra Novandi Barus
Pengantar Cloud Computing dengan AWS - Petra Novandi BarusPengantar Cloud Computing dengan AWS - Petra Novandi Barus
Pengantar Cloud Computing dengan AWS - Petra Novandi Barus
 
Dicoding Developer Coaching #36: Android | Pentingnya Performa pada Aplikasi ...
Dicoding Developer Coaching #36: Android | Pentingnya Performa pada Aplikasi ...Dicoding Developer Coaching #36: Android | Pentingnya Performa pada Aplikasi ...
Dicoding Developer Coaching #36: Android | Pentingnya Performa pada Aplikasi ...
 
Dicoding Developer Coaching #34: Android | Modular Android App dengan Dynamic...
Dicoding Developer Coaching #34: Android | Modular Android App dengan Dynamic...Dicoding Developer Coaching #34: Android | Modular Android App dengan Dynamic...
Dicoding Developer Coaching #34: Android | Modular Android App dengan Dynamic...
 
Dicoding Developer Coaching #35: Android | Setup Continuous Integration di An...
Dicoding Developer Coaching #35: Android | Setup Continuous Integration di An...Dicoding Developer Coaching #35: Android | Setup Continuous Integration di An...
Dicoding Developer Coaching #35: Android | Setup Continuous Integration di An...
 

Kürzlich hochgeladen

INDIAN GCP GUIDELINE. for Regulatory affair 1st sem CRR
INDIAN GCP GUIDELINE. for Regulatory  affair 1st sem CRRINDIAN GCP GUIDELINE. for Regulatory  affair 1st sem CRR
INDIAN GCP GUIDELINE. for Regulatory affair 1st sem CRRsarwankumar4524
 
Quality by design.. ppt for RA (1ST SEM
Quality by design.. ppt for  RA (1ST SEMQuality by design.. ppt for  RA (1ST SEM
Quality by design.. ppt for RA (1ST SEMCharmi13
 
Mathan flower ppt.pptx slide orchids ✨🌸
Mathan flower ppt.pptx slide orchids ✨🌸Mathan flower ppt.pptx slide orchids ✨🌸
Mathan flower ppt.pptx slide orchids ✨🌸mathanramanathan2005
 
SBFT Tool Competition 2024 -- Python Test Case Generation Track
SBFT Tool Competition 2024 -- Python Test Case Generation TrackSBFT Tool Competition 2024 -- Python Test Case Generation Track
SBFT Tool Competition 2024 -- Python Test Case Generation TrackSebastiano Panichella
 
Early Modern Spain. All about this period
Early Modern Spain. All about this periodEarly Modern Spain. All about this period
Early Modern Spain. All about this periodSaraIsabelJimenez
 
miladyskindiseases-200705210221 2.!!pptx
miladyskindiseases-200705210221 2.!!pptxmiladyskindiseases-200705210221 2.!!pptx
miladyskindiseases-200705210221 2.!!pptxCarrieButtitta
 
Simulation-based Testing of Unmanned Aerial Vehicles with Aerialist
Simulation-based Testing of Unmanned Aerial Vehicles with AerialistSimulation-based Testing of Unmanned Aerial Vehicles with Aerialist
Simulation-based Testing of Unmanned Aerial Vehicles with AerialistSebastiano Panichella
 
RACHEL-ANN M. TENIBRO PRODUCT RESEARCH PRESENTATION
RACHEL-ANN M. TENIBRO PRODUCT RESEARCH PRESENTATIONRACHEL-ANN M. TENIBRO PRODUCT RESEARCH PRESENTATION
RACHEL-ANN M. TENIBRO PRODUCT RESEARCH PRESENTATIONRachelAnnTenibroAmaz
 
THE COUNTRY WHO SOLVED THE WORLD_HOW CHINA LAUNCHED THE CIVILIZATION REVOLUTI...
THE COUNTRY WHO SOLVED THE WORLD_HOW CHINA LAUNCHED THE CIVILIZATION REVOLUTI...THE COUNTRY WHO SOLVED THE WORLD_HOW CHINA LAUNCHED THE CIVILIZATION REVOLUTI...
THE COUNTRY WHO SOLVED THE WORLD_HOW CHINA LAUNCHED THE CIVILIZATION REVOLUTI...漢銘 謝
 
Work Remotely with Confluence ACE 2.pptx
Work Remotely with Confluence ACE 2.pptxWork Remotely with Confluence ACE 2.pptx
Work Remotely with Confluence ACE 2.pptxmavinoikein
 
Dutch Power - 26 maart 2024 - Henk Kras - Circular Plastics
Dutch Power - 26 maart 2024 - Henk Kras - Circular PlasticsDutch Power - 26 maart 2024 - Henk Kras - Circular Plastics
Dutch Power - 26 maart 2024 - Henk Kras - Circular PlasticsDutch Power
 
PAG-UNLAD NG EKONOMIYA na dapat isaalang alang sa pag-aaral.
PAG-UNLAD NG EKONOMIYA na dapat isaalang alang sa pag-aaral.PAG-UNLAD NG EKONOMIYA na dapat isaalang alang sa pag-aaral.
PAG-UNLAD NG EKONOMIYA na dapat isaalang alang sa pag-aaral.KathleenAnnCordero2
 
PHYSICS PROJECT BY MSC - NANOTECHNOLOGY
PHYSICS PROJECT BY MSC  - NANOTECHNOLOGYPHYSICS PROJECT BY MSC  - NANOTECHNOLOGY
PHYSICS PROJECT BY MSC - NANOTECHNOLOGYpruthirajnayak525
 
Event 4 Introduction to Open Source.pptx
Event 4 Introduction to Open Source.pptxEvent 4 Introduction to Open Source.pptx
Event 4 Introduction to Open Source.pptxaryanv1753
 
DGT @ CTAC 2024 Valencia: Most crucial invest to digitalisation_Sven Zoelle_v...
DGT @ CTAC 2024 Valencia: Most crucial invest to digitalisation_Sven Zoelle_v...DGT @ CTAC 2024 Valencia: Most crucial invest to digitalisation_Sven Zoelle_v...
DGT @ CTAC 2024 Valencia: Most crucial invest to digitalisation_Sven Zoelle_v...Henrik Hanke
 
Engaging Eid Ul Fitr Presentation for Kindergartners.pptx
Engaging Eid Ul Fitr Presentation for Kindergartners.pptxEngaging Eid Ul Fitr Presentation for Kindergartners.pptx
Engaging Eid Ul Fitr Presentation for Kindergartners.pptxAsifArshad8
 
Chizaram's Women Tech Makers Deck. .pptx
Chizaram's Women Tech Makers Deck.  .pptxChizaram's Women Tech Makers Deck.  .pptx
Chizaram's Women Tech Makers Deck. .pptxogubuikealex
 
Genshin Impact PPT Template by EaTemp.pptx
Genshin Impact PPT Template by EaTemp.pptxGenshin Impact PPT Template by EaTemp.pptx
Genshin Impact PPT Template by EaTemp.pptxJohnree4
 
The Ten Facts About People With Autism Presentation
The Ten Facts About People With Autism PresentationThe Ten Facts About People With Autism Presentation
The Ten Facts About People With Autism PresentationNathan Young
 
Call Girls In Aerocity 🤳 Call Us +919599264170
Call Girls In Aerocity 🤳 Call Us +919599264170Call Girls In Aerocity 🤳 Call Us +919599264170
Call Girls In Aerocity 🤳 Call Us +919599264170Escort Service
 

Kürzlich hochgeladen (20)

INDIAN GCP GUIDELINE. for Regulatory affair 1st sem CRR
INDIAN GCP GUIDELINE. for Regulatory  affair 1st sem CRRINDIAN GCP GUIDELINE. for Regulatory  affair 1st sem CRR
INDIAN GCP GUIDELINE. for Regulatory affair 1st sem CRR
 
Quality by design.. ppt for RA (1ST SEM
Quality by design.. ppt for  RA (1ST SEMQuality by design.. ppt for  RA (1ST SEM
Quality by design.. ppt for RA (1ST SEM
 
Mathan flower ppt.pptx slide orchids ✨🌸
Mathan flower ppt.pptx slide orchids ✨🌸Mathan flower ppt.pptx slide orchids ✨🌸
Mathan flower ppt.pptx slide orchids ✨🌸
 
SBFT Tool Competition 2024 -- Python Test Case Generation Track
SBFT Tool Competition 2024 -- Python Test Case Generation TrackSBFT Tool Competition 2024 -- Python Test Case Generation Track
SBFT Tool Competition 2024 -- Python Test Case Generation Track
 
Early Modern Spain. All about this period
Early Modern Spain. All about this periodEarly Modern Spain. All about this period
Early Modern Spain. All about this period
 
miladyskindiseases-200705210221 2.!!pptx
miladyskindiseases-200705210221 2.!!pptxmiladyskindiseases-200705210221 2.!!pptx
miladyskindiseases-200705210221 2.!!pptx
 
Simulation-based Testing of Unmanned Aerial Vehicles with Aerialist
Simulation-based Testing of Unmanned Aerial Vehicles with AerialistSimulation-based Testing of Unmanned Aerial Vehicles with Aerialist
Simulation-based Testing of Unmanned Aerial Vehicles with Aerialist
 
RACHEL-ANN M. TENIBRO PRODUCT RESEARCH PRESENTATION
RACHEL-ANN M. TENIBRO PRODUCT RESEARCH PRESENTATIONRACHEL-ANN M. TENIBRO PRODUCT RESEARCH PRESENTATION
RACHEL-ANN M. TENIBRO PRODUCT RESEARCH PRESENTATION
 
THE COUNTRY WHO SOLVED THE WORLD_HOW CHINA LAUNCHED THE CIVILIZATION REVOLUTI...
THE COUNTRY WHO SOLVED THE WORLD_HOW CHINA LAUNCHED THE CIVILIZATION REVOLUTI...THE COUNTRY WHO SOLVED THE WORLD_HOW CHINA LAUNCHED THE CIVILIZATION REVOLUTI...
THE COUNTRY WHO SOLVED THE WORLD_HOW CHINA LAUNCHED THE CIVILIZATION REVOLUTI...
 
Work Remotely with Confluence ACE 2.pptx
Work Remotely with Confluence ACE 2.pptxWork Remotely with Confluence ACE 2.pptx
Work Remotely with Confluence ACE 2.pptx
 
Dutch Power - 26 maart 2024 - Henk Kras - Circular Plastics
Dutch Power - 26 maart 2024 - Henk Kras - Circular PlasticsDutch Power - 26 maart 2024 - Henk Kras - Circular Plastics
Dutch Power - 26 maart 2024 - Henk Kras - Circular Plastics
 
PAG-UNLAD NG EKONOMIYA na dapat isaalang alang sa pag-aaral.
PAG-UNLAD NG EKONOMIYA na dapat isaalang alang sa pag-aaral.PAG-UNLAD NG EKONOMIYA na dapat isaalang alang sa pag-aaral.
PAG-UNLAD NG EKONOMIYA na dapat isaalang alang sa pag-aaral.
 
PHYSICS PROJECT BY MSC - NANOTECHNOLOGY
PHYSICS PROJECT BY MSC  - NANOTECHNOLOGYPHYSICS PROJECT BY MSC  - NANOTECHNOLOGY
PHYSICS PROJECT BY MSC - NANOTECHNOLOGY
 
Event 4 Introduction to Open Source.pptx
Event 4 Introduction to Open Source.pptxEvent 4 Introduction to Open Source.pptx
Event 4 Introduction to Open Source.pptx
 
DGT @ CTAC 2024 Valencia: Most crucial invest to digitalisation_Sven Zoelle_v...
DGT @ CTAC 2024 Valencia: Most crucial invest to digitalisation_Sven Zoelle_v...DGT @ CTAC 2024 Valencia: Most crucial invest to digitalisation_Sven Zoelle_v...
DGT @ CTAC 2024 Valencia: Most crucial invest to digitalisation_Sven Zoelle_v...
 
Engaging Eid Ul Fitr Presentation for Kindergartners.pptx
Engaging Eid Ul Fitr Presentation for Kindergartners.pptxEngaging Eid Ul Fitr Presentation for Kindergartners.pptx
Engaging Eid Ul Fitr Presentation for Kindergartners.pptx
 
Chizaram's Women Tech Makers Deck. .pptx
Chizaram's Women Tech Makers Deck.  .pptxChizaram's Women Tech Makers Deck.  .pptx
Chizaram's Women Tech Makers Deck. .pptx
 
Genshin Impact PPT Template by EaTemp.pptx
Genshin Impact PPT Template by EaTemp.pptxGenshin Impact PPT Template by EaTemp.pptx
Genshin Impact PPT Template by EaTemp.pptx
 
The Ten Facts About People With Autism Presentation
The Ten Facts About People With Autism PresentationThe Ten Facts About People With Autism Presentation
The Ten Facts About People With Autism Presentation
 
Call Girls In Aerocity 🤳 Call Us +919599264170
Call Girls In Aerocity 🤳 Call Us +919599264170Call Girls In Aerocity 🤳 Call Us +919599264170
Call Girls In Aerocity 🤳 Call Us +919599264170
 

Play with Testing on Android - Gilang Ramadhan (Academy Content Writer at Dicoding)

  • 1. Gilang Ramadhan Academy Content Writer Dicoding Associate Android Developer Play with Testing on Android
  • 3. Specifications of the application Write the codes Test the application manually
  • 4.
  • 6. How to get started?
  • 7.
  • 8.
  • 9. ⬅, ➡, L1, L2, R1, R2, ⬆, ⬇, ⬅, ➡
  • 11. Follow best practices Built around modern design practices, Android Jetpack Libraries enable fewer crashes and less memory leaks with backwards-compatibility baked in. Eliminate boilerplate code Android Jetpack manages tedious activities like background tasks, navigation, and lifecycle management, so you can focus on what makes your app great. Reduce fragmentation Reduce complexity with libraries that work consistently across Android versions and devices. Why use Android Jetpack?
  • 12. Test
  • 16. “The percentage of your code that is executed by your tests” Test Coverage
  • 18. Test Driven Development The two cycles associated with iterative, test-driven development Source : Fundamentals of Testing
  • 19. is an application development method developed by testing. ● Writing Tests ● Running Tests ● Write down the Code ● Running Tests ● Refactor Code Test Driven Development
  • 20. ● More Productive ● Code is neater Safer ● Refactoring ● Minimizing Bug ● Documentation Advantages of using TDD
  • 22. ● Do not mock types you don’t own ● Don’t mock value objects ● Don’t mock everything ● Show love with your tests! Test Doubles
  • 26. REPLACE ME The important features of a testable architecture are: ● Each class should have a clearly defined purpose. ● Limit and be explicit about which classes know about other classes. ● Use constructor injection. ● Keep Android code out of the view model. Architecture Pattern
  • 27. 1. Local unit tests Located at module-name/src/test/java/. 2. Instrumented tests Located at module-name/src/androidTest/java/.
  • 28. 1. Run Toolbar. 2. Testing Toolbar. 3. Context Menu. 4. Test Status Icon. 5. Jump to Code.
  • 30.
  • 31.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37. Let’s Try Together Source: ● Advanced Android in Kotlin 05.1: Testing Basics Updated ● Advanced Android in Kotlin 05.2: Introduction to Test Doubles and Dependency Injection ● Advanced Android in Kotlin 05.3: Survey of Testing Topics
  • 38. What we've covered: ● How to run tests from Android Studio. ● The difference between local (test) and instrumentation tests (androidTest). ● How to write local unit tests using JUnit and Hamcrest. ● Setting up ViewModel tests with the AndroidX Test Library. Testing Basics Updated
  • 39. What we've covered: ● What you want to test and your testing strategy determine the kinds of test you are going to implement for your app. Unit tests are focused and fast. Integration tests verify interaction between parts of your program. End-to-end tests verify features, have the highest fidelity, are often instrumented, and may take longer to run. ● The architecture of your app influences how hard it is to test. ● To isolate parts of your app for testing, you can use test doubles. A test double is a version of a class crafted specifically for testing. For example, you fake getting data from a database or the internet. ● Use dependency injection to replace a real class with a testing class, for example, a repository or a networking layer. ● Use instrumented testing (androidTest) to launch UI components. ● When you can't use constructor dependency injection, for example to launch a fragment, you can often use a service locator. The Service Locator pattern is an alternative to Dependency Injection. It involves creating a singleton class called the "Service Locator", whose purpose is to provide dependencies, both for the regular and test code. Introduction to Test Doubles and Dependency Injection
  • 40. What we've covered: ● A review of testing coroutines from previous lessons, including covering the usage of runBlocking versus runBlockingTest. ● How to test coroutines that use viewModelScope by using TestCoroutineDispatcher ● TestCoroutineDispatcher's ability to pauseDispatcher and resumeDispatcher to control coroutine execution ● Testing error handling by updating a fake ● Testing your data layer, including your DAO and local data source ● Using IdlingResource (and the CountingIldingResource subclass) to write end to end tests that both include long running code and work with the data binding library. ● Testing global app navigation in an end to end test. Survey of Testing Topics
  • 41. Advantages of Testing Testing also provides you with the following advantages: ● Rapid feedback on failures. ● Early failure detection in the development cycle. ● Safer code refactoring, letting you optimize code without worrying about regressions. ● Stable development velocity, helping you minimize technical debt.
  • 42. “Code without tests is bad code” Michael Feathers, Working Effectively with Legacy Code