Mocks in constructor
-
I have
classAthat has constructor dependency onclassB. -
classBis class, does not have interface and is annotated withMockableannotation (REEDME instructions) and has its own constructor. -
Now I have test for
classAbut test can't be compiled because problems with automatically generated mock forclassB. -
Why I need mocks for
classBwhen they are not subject of test forclassA? -
It works when I create Mock from newly created custom interface.
-
CI pipelines are ok, and problem is local and flaky.
Usual errors:
-
Unresolved reference: Function0Mock -
Base declaration of supertype 'CoroutineDispatcher' needs opt-in. This is an internal kotlinx.coroutines API that should not be used from outside of kotlinx.coroutines. No compatibility guarantees are provided. It is recommended to report your use-case of internal API to kotlinx.coroutines issue tracker, so stable API could be provided instead. The declaration override must be annotated with '@kotlinx.coroutines.InternalCoroutinesApi' or '@OptIn(kotlinx.coroutines.InternalCoroutinesApi::class)'