google-developer-training / basic-android-kotlin-compose-training-workmanager

Apache License 2.0
30 stars 31 forks source link

Codelab: Advanced WorkManager and Testing #16

Open CheoR opened 1 year ago

CheoR commented 1 year ago

Write tests for Worker implementations

Specify the language of the codelab if it is not English:

In which task and step of the codelab can this issue be found?

Write a BlurWorker test cleanupWorker_doWork_resultSuccess.

Describe the problem

Example test code results in error and does not match final code in main branch.

... 
           assertThat(result, `is`(ListenableWorker.Result.success()))
... 

// main branch
... 
           assertTrue(result is ListenableWorker.Result.Success)
... 

Versions Android Studio version: 2022.3.1. Patch 2 API version of the emulator:

Additional information Include screenshots if they would be useful in clarifying the problem.

image

entropia9 commented 11 months ago

It's part of Hamcrest, it should come bundled with JUnit. image

I don't know why they used that instead of assertTrue, though.