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.
Challenge: Add another unit test for database logic - Android Tutorial
From the course: Building an Android App with Jetpack Libraries
Challenge: Add another unit test for database logic
(upbeat music) - Once you've created a database test class, you can use it to run multiple tests. Each test class can have multiple test functions. The before code and the after code will be executed automatically by the testing framework before and after each of these tests. In this challenge, I'm going to ask you to create an instance of the note entity class. To set its text value to some value, and then to insert it into the database. Then retrieve that same value from the database. Here's a couple of hints. I'm going to recommend using the constructor that has no arguments to create the object initially, and then set the text property in a separate statement. Then when you insert that object into the database, SQLite will automatically create a new note ID. And if it's the first database row, which will be because you're starting off with a fresh database, the ID should be one. After you insert the data,…
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
-
-
-
-