We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Mockks should be injected in all superclasses and not just the top most parent
kotlin.UninitializedPropertyAccessException: lateinit property convertApplicationService has not been initialized
abstract class Grandparent { @Autowired private lateinit var serviceA: ServiceA open fun doSomething() { // serviceA has been injected correctly serviceA.doIt() } } abstract class Parent : Grandparent() { @Autowired lateinit var serviceB: ServiceB override fun doSometing() { super.doSomething() // Failure happens here, serviceB has not been initialized serviceB.doIt() } } class Child: Parent() { @Autowired lateinit var serviceC: ServiceC override fun doSomething() { super.doSomething() // serviceC has been injected correctly serviceC.doIt() } } @ExtendWith(MockkExtension::class) class ChildTest { @Mockk private lateinit var serviceA: ServiceA @Mockk private lateinit var serviceB: ServiceB @Mockk private lateinit var serviceC: ServiceC @InjectMockks private lateinit var child: Child @Test fun theTest () { child.doSomething() } }
The text was updated successfully, but these errors were encountered:
Hi @drennerpfc6 , Did you use MockKAnnotations.init() in your test or not ?
MockKAnnotations.init()
Sorry, something went wrong.
@OmarBeshary the test class is using MockkExtension so MockkAnnotations.init() is not required.
No branches or pull requests
Expected Behavior
Mockks should be injected in all superclasses and not just the top most parent
Minimal reproducible code (the gist of this issue)
The text was updated successfully, but these errors were encountered: