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

Challenge: Add another unit test for database logic - Android Tutorial

From the course: Building an Android App with Jetpack Libraries

Start my 1-month free trial

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