JUnit4 examples:
class SomeTestWithDatabase {
@Rule
@JvmField
val roomDatabaseRule = RoomDatabaseRule<MyDatabase>()
@RoomDao
lateinit var fooDao: FooDao
// ...
}
JUnit5 examples:
@ExtendWith(RoomDatabaseExtension::class)
class SomeTestWithDatabase {
@RoomDao
lateinit var fooDao: FooDao
// ...
}
Questions:
- How to provide database type to the extension? (easy with rules)
- How to provide advanced database configuration (callbacks, migrations, allow main thread queries, in-memory, etc.) without complicating tests too much?
- Does this really improve the readability of the tests?
JUnit4 examples:
JUnit5 examples:
Questions: