
Explore a practical, hands-on introduction to Android testing, guiding beginners from basics to advanced UI testing with JUnit and Jetpack Compose testing.
Learn why testing matters in software development and master Android testing with Jetpack Compose, covering unit, integration, end-to-end tests, and test driven development for maintainable, testable apps.
Develop a practical foundation for Android testing by reviewing basic Android development concepts such as activities, Dagger, Hilt, and room databases, and by exploring Jetpack Compose states and composition.
Assess your fit for this course as an intermediate Android developer seeking to sharpen skills. Master testing in Android apps and write test cases for UI tests with Jetpack Compose.
Learn how manual testing contrasts with automated testing, then use unit tests and user-action scripts to verify code works as intended, offering faster, scalable bug catching as apps grow.
Explore how testing ensures software reliability, illustrated by the Mars Climate Orbiter unit mismatch and its costly failure, and learn how thorough tests build robust, failure-resilient applications.
Explore the four software testing levels: unit, integration, system, and acceptance tests, and learn how each verifies components, interactions, the full application, and business requirements.
Run local tests on the JVM without the Android framework to validate pure business logic. Rely on instrumented tests on real devices or emulators for Android resources and end-to-end scenarios.
Identify flaky tests and their causes, including concurrency issues, external dependencies, and non-deterministic behavior, then mitigate by isolation with mocks and stable environments like docker to test various inputs.
Assess the scope of code to test, from unit to end-to-end, balancing fidelity and speed. The testing pyramid recommends 70% unit, 20% integration, and 10% end-to-end tests.
Discover how test driven development (tdd) uses tests as a design guide, write the test first, implement minimal code to pass, and refactor while keeping tests passing.
The case study uses a speed formula (distance over time) to show how negative or zero inputs yield incorrect results, and stresses throwing exceptions and input validation for production-ready code.
Architect a testable Android app by separating UI, domain, and data layers, and applying unidirectional data flow with a single source of truth driven by Jetpack Compose states.
Learn to write unit tests in Android, create test cases for the happy path and sad path, and write UI tests in Jetpack Compose.
Get started by downloading the starter code from the resource folder provided with the course description, extract it, and open the starter project similar to this one.
Explore a starter Jetpack Compose tip calculator app with a tip data class, repository, and home view model; enter bill amount and tip percent, then calculate and view the result.
Explore Android Studio project source sets, including Android test and unit test, and learn how to run instrumentation tests on Android resources via emulator or unit tests via the JVM.
Explore how android dependencies are organized into implementation, testImplementation, androidTestImplementation, and debugImplementation, with distinct source sets and tooling for local, instrumented, and UI testing.
Test the repository in isolation by writing the first unit test for the tip calculator, and set up a clear test folder structure with Android Studio using JUnit 4.
Annotate a function with @Test to enable JUnit, implement given-when-then steps, and verify tip calculation with assertions using the Truth library in a unit test while addressing rounding errors.
Showcases solving test case 2 with 0% tip, where the tip calculator returns zero for a 100 unit bill. Confirm by asserting zero and rerunning to pass.
Explore edge-case testing for a tip calculator by adopting a test-first approach, using JUnit assertions to expect an illegal argument exception on negative input, then implement code to pass tests.
Handle a negative bill amount by throwing an illegal argument with the message bill cannot be negative in the tip calculator, then rerun tests to verify success.
Click run to execute all tests in the repository, instantiating each test and verifying that all tests pass.
Explore viewmodel testing basics by writing pure unit tests that avoid Android OS dependencies, using setup and teardown to initialize resources, and recognize local tests as faster than instrumented tests.
Test a viewmodel tip calculation by constructing a tip, calling the repository to compute it, and updating the state, shown with a 10% tip on 200 dollars equals 20.
Demonstrates how a reset in the home view model returns the state to the initial home state. The test toggles a value (10% of 100.0) before resetting.
Showcases testing a get tip amount function for a negative bill amount, ensuring it fails gracefully with a not null error to validate assignment 3 test cases.
Explore test case 3 of assignment 3 in android testing with jetpack compose, showing graceful error handling in get tip when tip percent exceeds 100% and verifying the error message.
Learn how to test that the error state clears when the user provides the correct tip input, ensuring the home view model resets errors to null.
Unit testing in Android ensures code quality, reliability, and maintainability with clear tests and meaningful names, aiming for 100% code coverage. It catches bugs early and boosts confidence before production.
Explore how to write instrumentation tests for a Jetpack Compose UI, using AndroidJUnit4+ runner and instrumentation registry to access context and resources on an emulator or device.
Create your first UI test for the home screen by generating a test case, selecting Android resource, and generating the test directory for the home CT test.
Access compose components with JUnit rule by using a compose test rule to set content and interact with composables, while wiring a repository and home view model.
Learn to inspect the semantic tree of your Jetpack Compose with the compose test rule, print log, and access composables via node functions for robust testing.
Explore how instrumented testing ensures quality for Jetpack Compose apps, using the Android JUnit runner and Compose test rule to interact with composables and simulate user actions.
Write a test case for the newsy app using clean architecture and MVVM with Jetpack Compose, paging 3, and a local cache.
Explore a modular Android architecture with Dagger Hilt for dependency injection, feature modules, Room database, DTO-to-entity mappers, and a Retrofit-backed remote mediator for a single source of truth.
Write unit tests for article mapping extension functions that convert to headline and discover article DTOs, verify formatting, and handle null or empty values with unknown defaults in Jetpack Compose.
Test edge cases in article mapping by validating empty categories and negative pages, asserting illegal argument exception and index out of bound exception with defensive Java and JUnit.
Learn how to test a headline mapper in an Android app using Jetpack Compose, creating from-model and to-model conversions and asserting mapped fields in tests.
Learn how to test Room databases locally using Robolectric, covering DAOs, the SQLite abstraction, and why device tests aren’t ideal for consistent results.
Discover how Robolectric runs unit tests on the JVM without emulators or devices, enabling fast, local Android testing with simulated components, Room databases, and mocking Android behavior.
Annotate tests with the Robolectric test runner to run Android unit tests on the JVM, configure with manifest none, and initialize DAOs and the news article database.
Learn to test coroutines using a main dispatcher rule and test watcher, with an unconfined dispatcher, and set up an in-memory Room database for each test.
Explore testing strategies for Android paging with Jetpack Compose, using a dao-based paging source, simulating loads, and extending tests with a get test data utility to validate paging results.
Perform the first Dao test by inserting an expected item, running a suspend test with runTest, and asserting fetched data with Google Truth.
test deleting all non-favorite articles by inserting a mix of favorite and non-favorite items, invoking the delete-all query, and asserting that only the favorite article remains in the database.
Practice testing the network layer of an Android app using retrofit by implementing the API described in the lesson, building on prior local database tests.
Explore how test doubles enable isolated, fast, and reliable Android tests by substituting real dependencies with mocks, stubs, fakes, spies, and dummies.
Set up square's mock web server for testing, add testImplementation dependencies in build.gradle for Retrofit tests, and enable instrumentation tests to prepare API test cases.
Write a unit test for the headline API using a mock web server, JSON with Kotlin serialization, and a converter factory, with setup and teardown and a clean shutdown.
Set up json response mock data by creating json files in the test resources and reading them with a file reader to simulate invalid and success API responses.
Create a mock response file reader to load json files from resources via input streams and use for safe closing, tests asserting content equals success.
Test a Retrofit network API with mock web server to verify endpoints, query parameters, and error handling using success responses and io exceptions.
Learn how RemoteMediator synchronizes local cache with a Rest API, testable via in-memory database and mock web server, including initialization paths: initial skip refresh and initial launch initial refresh.
Set up a remote mediator test with a Robolectric in-memory database and a mock web server, integrating local and network data sources.
Test cache behavior in a RemoteMediator by simulating valid and expired caches with coroutines and time units, asserting keepInitialRefresh or launch/initial refresh outcomes.
Test the remote mediator's loading flow in Android by simulating network responses, asserting data insertion into the database, and validating error handling and end-of-pagination scenarios.
Learn how Mockito, a popular Java library, creates mock objects for unit tests, allowing you to stub methods, configure and verify objects, and isolate unit under test by removing dependencies.
Set up Mockito in the repository test by adding dependencies in build.gradle (Mockito 5.12, Mockito Kotlin), configure the JUnit runner, annotate mocks, and initialize the mapper and repository before test.
Learn to write the first repository test with Mockito, mocking remote mediator and paging source to validate headline article fetching using coroutines and a main dispatcher.
Learn to test parameter assignment in a repository by writing cases with Mockito to verify category, country, and language, and to test update favorite article using a suspend function.
Learn to test the headline use cases by mocking the repository with Mockito or using a fake test double, then compose fetch and update use cases for the view model.
Create a fake headline repository and paging setup to test the fetch headline use case, validate test cases, and ensure exception handling for empty category, country code, or language code.
Create a headline view model test in isolation by injecting a fake setting repository and testing the headline and setting use cases, including resource states like success and loading.
Set up a fake repository, construct headline use case and setting use case, initialize the headline view model, and apply a coroutine rule to test the view model.
Test a headline view model by validating init fetch, settings updates, and favorite toggles using runTest, asserts, and snapshots to confirm correct headline state and paging data behavior.
Learn how Dagger Hilt enables Android tests to inject production-like dependencies, reduce mocks, and create new test components automatically for easier, more reliable integration testing.
Learn to set up dagger hilt in tests by annotating with hilt android test, inject dependencies via hilt components, and coordinate hilt android rule with compose test rule for tests.
Learn to implement a custom Hilt test runner for Android instrumented tests by extending the Android JUnit runner, providing a Hilt-enabled application, and configuring Gradle to register Hilt test runner.
Replace production modules with test modules in Dagger Hilt using test install in to swap modules with fake ones, like news local module and in-memory database builder.
Uninstall modules let you disable specific dependencies in a single test by annotating the test and listing modules to avoid, enabling replacement with the local module.
Set up a mock web server, add Android test resources to the project, and create a utils package with a mock response file reader to avoid file not found errors.
Configure a reusable set content helper to launch the activity with dagger hilt, initialize a navigation host, and render the headline screen via a single composable for consistent tests.
Develop a Jetpack Compose Android test for the headline screen by mocking API responses, asserting header and article display, and addressing http vs https rules in debug.
Create an XML network security config to permit clear text traffic and register it in the Android manifest. Use Gradle to set debug clear_text to true and release to false.
Configure Android architecture components testing with an instant task executor rule to make data load instantaneously, test LiveData reliably, and inject data with Dagger Hilt in your screen tests.
Unit test the home screen UI in isolation with Jetpack Compose, exploring states and tags. Inject fake lazy paging data and verify scrolling and article display with compose test rules.
Demonstrates testing error handling in a headline screen by using a snackbar instead of a toast, simulating refresh, prepend, and append load states, and asserting the network error message appears.
learn how to run all instrumented tests at once in an android app, observe test execution across cases, and see all tests pass.
Write instrumented tests for the new app, adding test tags for the drawer content and the newsy logo with semantics and content descriptions.
Verify app launch by locating a node with a content description and asserting the home screen shows news and hot news, using an Android Compose rule and mock JSON responses.
Develop and validate navigation drawer flows with a jetpack compose test across home, drawer, favorite, and settings screens, using test tags and content descriptions.
Learn to run ui tests locally with robolectric for jetpack compose, configure test dependencies, and verify a three-tab modal navigation drawer with compose test rules.
Run all unit tests to verify the app, observe that tests pass, check the app state, fix breaks, and understand what the application is supposed to do.
Are you new to Android testing and looking to build a strong foundation? Join my comprehensive course designed specifically for beginners. As an experienced Android developer, I'll guide you through the essential concepts and tools needed to write effective tests for your Android applications.
I have had the privilege of teaching thousands of students through platforms like YouTube and Udemy. In this course, you will embark on a comprehensive journey, starting from the fundamentals of Android testing, including Room databases, Retrofit, Jetpack Compose, and Dagger Hilt, with a focus on both local and instrumented testing.
You'll gain hands-on experience with testing frameworks like JUnit, Robolectric and Compose Testing throughout the course. You'll learn the principles of writing tests and how to implement them in real-world projects, helping you build robust applications that stand out in the job market.
Why choose this course?
Beginner-friendly: This course is tailored to those with little to no experience in Android testing.
Practical focus: Learn through real-world examples and exercises to reinforce your understanding.
Up-to-date content: Stay current with the latest Android testing techniques and tools, including Jetpack Compose.
Clear explanations: I'll break down complex concepts into easy-to-understand terms.
By the end of this course, you'll have a solid understanding of Android testing principles and be able to write effective tests for your projects.