Sign In Start Free Trial
Account

Add to playlist

Create a Playlist

Modal Close icon
You need to login to use this feature.
  • Book Overview & Buying Mastering Kotlin for Android 14
  • Table Of Contents Toc
  • Feedback & Rating feedback
Mastering Kotlin for Android 14

Mastering Kotlin for Android 14

By : Wangereka
5 (9)
close
close
Mastering Kotlin for Android 14

Mastering Kotlin for Android 14

5 (9)
By: Wangereka

Overview of this book

Written with the best practices, this book will help you master Kotlin and use its powerful language features, libraries, tools, and APIs to elevate your Android apps. As you progress, you'll use Jetpack Compose and Material Design 3 to build UIs for your app, explore how to architect and improve your app architecture, and use Jetpack Libraries like Room and DataStore to persist your data locally. Using a step-by-step approach, this book will teach you how to debug issues in your app, detect leaks, inspect network calls fired by your app, and inspect your Room database. You'll also add tests to your apps to detect and address code smells. Toward the end, you’ll learn how to publish apps to the Google Play Store and see how to automate the process of deploying consecutive releases using GitHub actions, as well as learn how to distribute test builds to Firebase App Distribution. Additionally, the book covers tips on how to increase user engagement. By the end of this Kotlin book, you’ll be able to develop market-ready apps, add tests to their codebase, address issues, and get them in front of the right audience.
Table of Contents (22 chapters)
close
close
1
Part 1: Building Your App
6
Part 2: Using Advanced Features
12
Part 3: Code Analysis and Tests
16
Part 4: Publishing Your App

Testing the network and database layers

In this section, we are going to learn how to write tests for our network and database layers step by step.

Testing the network layer

To test our network layer, we will write unit tests. However, since we are using Retrofit to make our network requests, we will use MockWebServer to mock our network requests. The MockWebServer is a library that allows us to mock our network requests. Let us start by setting up the test dependencies in our version catalog:

  1. Open the libs.version.toml file and add the following versions in the versions section:
    mockWebServer = "5.0.0-alpha.2"
    coroutinesTest = "1.7.3"
    truth = "1.1.5"

    We are setting up the versions for mockWebServer, coroutinesTest, and truth.

  2. Next, in the libraries section, add the following:
    test-mock-webserver = { module = "com.squareup.okhttp3:mockwebserver", version.ref = "mockWebServer" }
    test-coroutines = { module = "org.jetbrains...

Unlock full access

Continue reading for free

A Packt free trial gives you instant online access to our library of over 7000 practical eBooks and videos, constantly updated with the latest in tech

Create a Note

Modal Close icon
You need to login to use this feature.
notes
bookmark search playlist download font-size

Change the font size

margin-width

Change margin width

day-mode

Change background colour

Close icon Search
Country selected

Close icon Your notes and bookmarks

Delete Bookmark

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Delete Note

Modal Close icon
Are you sure you want to delete it?
Cancel
Yes, Delete

Edit Note

Modal Close icon
Write a note (max 255 characters)
Cancel
Update Note

Confirmation

Modal Close icon
claim successful

Buy this book with your credits?

Modal Close icon
Are you sure you want to buy this book with one of your credits?
Close
YES, BUY