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.
Solution: Add another unit test for database logic - Android Tutorial
From the course: Building an Android App with Jetpack Libraries
Solution: Add another unit test for database logic
(upbeat music) - [Instructor] For this challenge, I asked you to create a new test for your database. Create a note object, set its text value and insert it into the database. Then retrieve the data based on the expected primary key or unique ID of one, for the first row in the database table, then compare the ID to the expected value and if those values match, then the test succeeds. Here's my solution, I'll create a new test function and I'll name it insertNote, the name of the function could be anything you want. Next I'll create a new Note object using the note entity classes, no arguments constructor. Then I'll set the notes text property to anything. It'll just be some text then out insert that note object into the database using dao dot insert note and I'll pass in the note object. Next, I'll retrieve that note from the database table. I'll create a new variable that I'll call saved note and I'll use dao…
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
-
-
-
-