'Run Cucumber tests for Android Room ORM framework
I want to try BDD using Cucumber on Android. I have succeeded running Cucumber tests on plain Java/Kotlin objects but I'm not able to run Instrumentational tests for the database objects. This is an example of my androidTest classes:
@RunWith(AndroidJUnit4::class)
class AccountDaoTest {
private lateinit var accountDao : AccountDao // Dao Object that runs queries
private lateinit var database : BlackPepperDatabase //Database
@Before
fun createDataBase() {
val context = ApplicationProvider.getApplicationContext<Context>() //Retrieve the database from application provider.
database = Room.inMemoryDatabaseBuilder(
context, BlackPepperDatabase::class.java
).build()
accountDao = database.accountDao()
}
@After
@Throws(IOException::class)
fun closeDatabase() {
database.close()
}
@When("user creates a new account")
fun writeAccountAndRetrieveIt(): Unit = runBlocking {
// Run tests where I can insert and retrieve data.
}
}
On the previous example, I get an exception that says:
No instrumentation registered! Must run under a registering instrumentation
Has anyone here run Cucumber tests for Android Room?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
