Writing your first test
Locate the root package of your unit tests and create a new class called NoteTest as follows:
package com.journaler
import android.location.Location
import com.journaler.database.Content
import com.journaler.model.Note
import org.junit.Test
class NoteTest {
@Test
fun noteTest() {
val note = Note(
"stub ${System.currentTimeMillis()}",
"stub ${System.currentTimeMillis()}",
Location("Stub")
)
val id = Content.NOTE.insert(note)
note.id = id
assert(note.id > 0)
}
} The test is very simple. It creates a new instance of Note, triggers the CRUD operation in our content provider to store it, and verifies the ID received. To run the test, right-click on class from the Project pane and choose Run 'NoteTest':

The unit test is executed like this:

As you can see, we successfully inserted our Note into the database. Now,...