I use Room and try to test my db locally using robolectric.
In room you can specify the schema export by
sourceSets {
androidTest.assets.srcDirs += files("$projectDir/schemas".toString())
}
However these assets are not picked up by robolectric and the android.arch.persistence.room.testing.MigrationTestHelper fails because it does not find the schema in the assets.
4.0.0-alpha2
Android 27
I found a workaround.
Using test.assets.srcDirs did not work, but adding them to debug.assets.srcDirs worked.
I'm going to close this. Android Studio now has first class support for Robolectric (merges and compiles resources in your deps). I don't think it supports assets in the tests folder however but if you'd like that please open an issue on the google tracker for Android Studio
If you want to utilize these assets to unit test your release build(s) as well, release.assets.srcDirs does the trick. Thanks!
Most helpful comment
I found a workaround.
Using
test.assets.srcDirsdid not work, but adding them todebug.assets.srcDirsworked.