mockative icon indicating copy to clipboard operation
mockative copied to clipboard

Mocks in constructor

Open DavidGrygar opened this issue 1 year ago • 0 comments

  • I have classA that has constructor dependency on classB.

  • classB is class, does not have interface and is annotated with Mockable annotation (REEDME instructions) and has its own constructor.

  • Now I have test for classA but test can't be compiled because problems with automatically generated mock for classB.

  • Why I need mocks for classB when they are not subject of test for classA?

  • 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)'

DavidGrygar avatar Jul 03 '24 11:07 DavidGrygar