Daniele Segato
09/08/2020, 3:38 PM`when`<Asset>(adapter.assetGetToAsset(input))
.then {
delay(300L)
output
}
this simple thing I can't do because then
doesn't give me a coroutine context.
Do you use Mockk? Some other libraries? What are the pros and cons?
Bonus question: is there some best practice to test when you have final classes? (which are the default in kotlin).Casey Brooks
09/08/2020, 4:11 PMcoEvery { }
and running suspending code as an answer to a mocked function (coAnswers { }
), and it works very well in my experience. To my knowledge, it is the only kotlin-specific option for mocking.
The API is very similar to Mockito, and it’s very easy to migrate from one to the other. You can run both Mockito and Mockk in the same test suite so you can just write your new tests in Mockk without having to rewrite your old tests. I don’t know if you can use both libraries in the same test, though, so I’d suggest for each test class you just use one or the other.Daniele Segato
09/08/2020, 4:14 PMCasey Brooks
09/08/2020, 4:22 PMDaniele Segato
09/08/2020, 4:23 PMMatteo Mirk
09/09/2020, 7:24 AMDaniele Segato
09/09/2020, 7:30 AMMatteo Mirk
09/09/2020, 7:41 AMopen
, so it’s final when you compile and you have all the expected checks but effectively non-final at runtime.
not completely sure but it manipulates bytecode at compile-time, making the class