Writing our first test with Kotlin
In this section, we will start with a slow introduction to test writing by creating a couple of simple tests. Locate your src/test
directory and, under the com.journaler
package, create a new class called NoteTest
:
package com.journaler import org.junit.Test class NoteTest { @Test fun testNoteInsert(){ } }
We just defined an empty test that, at this point, doesn't do anything. Despite this, we introduced some very important things. We used the @Test
annotation that will tell the test framework which method will represent test implementation. We are not limited to only one test per test class, so let's add a couple more tests in our test class:
package com.journaler import org.junit.Test class NoteTest { @Test fun testNoteInsert(){ } @Test fun testNoteUpdate(){ } @Test fun testNoteDelete(){ } @Test fun testNoteSelect(){ } }
Now, we have four tests in our NoteTest...