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鈥檒l 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

Projects
None yet
4 participants
@tonilopezmr
Copy link
Contributor

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!

Fix spring mocking injection @MockBean @MockkBean
Using prepareTestInstance loads the complete test stack instance, not only Autowired fields.
@Kerooker

This comment has been minimized.

Copy link
Member

commented Feb 18, 2019

Great one!

@sksamuel Let's sneak this into 3.3.0?

@sksamuel

This comment has been minimized.

Copy link
Member

commented Feb 18, 2019

This is most beautifully formatted pull request ever.

@Kerooker

This comment has been minimized.

Copy link
Member

commented Feb 18, 2019

And commit + commit message

@sksamuel

This comment has been minimized.

Copy link
Member

commented Feb 18, 2019

We should do the same for the ConstructorExtension

@sksamuel sksamuel merged commit 45589a0 into kotlintest:master Feb 18, 2019

2 checks passed

continuous-integration/appveyor/pr AppVeyor build succeeded
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
@tonilopezmr

This comment has been minimized.

Copy link
Contributor Author

commented Feb 18, 2019

@sksamuel sksamuel referenced this pull request Feb 18, 2019

Closed

KotlinTest Roadmap 3.3 #628

19 of 20 tasks complete
@mindhaq

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Member

commented Feb 22, 2019

@tonilopezmr

This comment has been minimized.

Copy link
Contributor Author

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

This comment has been minimized.

Copy link

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

This comment has been minimized.

Copy link
Member

commented Feb 22, 2019

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

@tonilopezmr tonilopezmr referenced this pull request Feb 27, 2019

Merged

Using MockMvc with Mockk #2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can鈥檛 perform that action at this time.