New issue

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

lateinit property has not been initialized #47

Closed
alexxxdev opened this Issue Mar 19, 2018 · 2 comments

Comments

2 participants
@alexxxdev

alexxxdev commented Mar 19, 2018

I have this code:

interface IFoo

class Foo:IFoo {
	fun method(){
		// ...
	}
}

abstract class AbstractBar<T:IFoo>{
    @Inject
    lateinit var foo: T
}



class Bar: AbstractBar<Foo>() {
    fun call(){
        foo.method()
    }
}

class Test {
    @MockK
    lateinit var foo: Foo

    @InjectMockKs lateinit var bar: Bar

    @Before
    fun setUp() = MockKAnnotations.init(this)


    @Test
    fun test() {
        every { foo.method() } answers { nothing }
        bar.call()
        verify { foo.method() }
    }
}

and it produces an error:
kotlin.UninitializedPropertyAccessException: lateinit property foo has not been initialized

mockk version: 1.7.12

What do I need to do to get it right? or is it a bug?

@oleksiyp

This comment has been minimized.

Collaborator

oleksiyp commented Mar 19, 2018

Think it is a bug. Will check in the evening why it is happening. Thanks

@oleksiyp oleksiyp closed this in ffdf0ee Mar 19, 2018

@oleksiyp

This comment has been minimized.

Collaborator

oleksiyp commented Mar 19, 2018

Fixed in 1.7.13. Should be synced soon in maven repo. Github autoclosed ticket

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment