From the course: Building an Android App with Jetpack Libraries
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Create a unit test for database logic - Android Tutorial
From the course: Building an Android App with Jetpack Libraries
Create a unit test for database logic
- Before, continuing my work on the app, I want to test my database logic with an Android JUnit test. First, I'm going to add another function to my data access object, to report how many rows there are in the notes database. I'll create a new query and I'll set the SQL statement to look like this. Select count of asterisk from, and then the notes table. And I'll set that as a function called get count and it'll return an integer. So now I'll be able to easily query the database table and find out how many rows there are. Next I'll go over to the project window and I'll go to this version of the base package, that's labeled Android test, and I'll open this class named example instrumented test that was created for me. This is an example of a JUnit test. Now I'm going to leave this sample code alone, so I'm going to copy and then paste to create a new class, and I'll call this one database test. I'll get rid of these…
Contents
-
-
-
-
-
-
Turn a data class into a Room entity3m 3s
-
(Locked)
Implement database operations in a DAO4m 7s
-
(Locked)
Create a custom type converter2m 14s
-
(Locked)
Define an SQLite database with Room4m 31s
-
(Locked)
Create a unit test for database logic5m 11s
-
(Locked)
Challenge: Add another unit test for database logic1m 27s
-
(Locked)
Solution: Add another unit test for database logic3m 3s
-
-
-
-