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

Fix Spring mocking injection @MockBean @MockkBean #684

Merged
merged 1 commit into from
Feb 18, 2019

Conversation

tonilopezmr
Copy link
Contributor

@tonilopezmr tonilopezmr commented Feb 18, 2019

💣 Issue

  • Using the current version only supports @Autowired injections but not mocked injections because the implementation only takes care about Autowired objects.

🎩 What is the goal?

📝 How is it being implemented?

I hope we can improve Kotlintest integration with Spring ❤️, thanks!

Using prepareTestInstance loads the complete test stack instance, not only Autowired fields.
@LeoColman
Copy link
Member

Great one!

@sksamuel Let's sneak this into 3.3.0?

@sksamuel
Copy link
Member

This is most beautifully formatted pull request ever.

@LeoColman
Copy link
Member

And commit + commit message

@sksamuel
Copy link
Member

We should do the same for the ConstructorExtension

@sksamuel sksamuel merged commit 45589a0 into kotest:master Feb 18, 2019
@tonilopezmr
Copy link
Contributor Author

We use it at Karumi a lot

@sksamuel sksamuel mentioned this pull request Feb 18, 2019
20 tasks
@mindhaq
Copy link
Contributor

mindhaq commented Feb 22, 2019

Is this already part of 3.3.0-RC3?

If so, it's not working for me. I still get this when the test makes the first mock-wiring call:

kotlin.UninitializedPropertyAccessException: lateinit property service has not been initialized

@sksamuel
Copy link
Member

sksamuel commented Feb 22, 2019 via email

@tonilopezmr
Copy link
Contributor Author

tonilopezmr commented Feb 22, 2019

@mindhaq Did you added the SpringListener ?

If you could share the code, I can take a look. I'm using 3.3.0-RC3, and it is working.

@mindhaq
Copy link
Contributor

mindhaq commented Feb 22, 2019

@tonilopezmr ah! my bad, I though adding the SpringAutowireConstructorExtension would be enough. Should have read the docs more thoroughly.

Thanks for the hint, now it works like a charme.

@sksamuel
Copy link
Member

The SpringListener does field injection and the SpringAutowireConstructorExtension does constructor based injection.

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

Successfully merging this pull request may close these issues.

4 participants