我有与Room交互的WorkManager。
class EchoWorker(context: Context, parameters: WorkerParameters)
: Worker(context, parameters), KoinComponent {
val repository: Repository by inject()
override fun doWork(): Result {
repository.getLastGame(5)
return Result.success(inputData)
}
}
@Test
@Throws(Exception::class)
fun testPeriodicWork() {
// Define input data
val input = workDataOf(KEY_1 to 1, KEY_2 to 2)
// Create request
val request = PeriodicWorkRequestBuilder<EchoWorker>(15, MINUTES)
.setInputData(input)
.build()
val workManager = WorkManager.getInstance()
val testDriver = WorkManagerTestInitHelper.getTestDriver()
// Enqueue and wait for result.
workManager.enqueue(request).result.get()
// Tells the testing framework the period delay is met
testDriver.setPeriodDelayMet(request.id)
// Get WorkInfo and outputData
val workInfo = workManager.getWorkInfoById(request.id).get()
// Assert
assertThat(workInfo.state, `is`(WorkInfo.State.ENQUEUED))
}
当我运行此简单测试时,它会给我:
Cannot find a version of 'androidx.room:room-runtime' that satisfies
the version constraints:
如何解决这个问题?
(这用于StackOverFlow.com :): Lorem ipsum dolor坐下,一直保持着安静的状态。 Nullam venenatis tincidunt溃疡。整形贝母的占卜术。 Cras nec调味品色情。 Donec lacinia ante sed特鲁斯大黄蜂易感。