Skip to content
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
Closed

lateinit property has not been initialized #47

alexxxdev opened this issue Mar 19, 2018 · 2 comments

Comments

@alexxxdev
Copy link

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
Copy link
Collaborator

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

@oleksiyp
Copy link
Collaborator

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
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants