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

How to use @SpykBeans and @MockkBeans? #113

Open
dAnjou opened this issue Mar 13, 2024 · 0 comments
Open

How to use @SpykBeans and @MockkBeans? #113

dAnjou opened this issue Mar 13, 2024 · 0 comments

Comments

@dAnjou
Copy link

dAnjou commented Mar 13, 2024

Hi,

in my Spring Boot + Kotlin codebase I have a @RestController asking for various dependencies via constructor injection. Most of these dependencies in turn ask for other dependencies themselves. So far nothing unusual, I guess.

Now I'd like to write a few tests where I use some of the dependencies but about others I don't care so much.

But I still need to make them available as Beans.

So, I've been @SpykBeaning each individual one of those I don't care about:

@SpykBean
private lateinit var lorem: Lorem
@SpykBean
private lateinit var ipsum: Ipsum
@SpykBean
private lateinit var dolor: Dolor

But I thought maybe there is an easier/shorter way, so I found @SpykBeans (plural):

@SpykBeans(
    SpykBean(Lorem::class),
    SpykBean(Ipsum::class),
    SpykBean(Dolor::class)
)
internal class irrelevantComponents

The former works, the latter doesn't, Spring can't find the beans. Am I using this wrong?

🙏

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

1 participant