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

NativeTest (aotTestClasses) fails on the mock bean. #37480

Closed
hadson172 opened this issue Sep 20, 2023 · 4 comments
Closed

NativeTest (aotTestClasses) fails on the mock bean. #37480

hadson172 opened this issue Sep 20, 2023 · 4 comments
Labels
for: external-project For an external project and not something we can fix status: invalid An issue that we don't feel is valid

Comments

@hadson172
Copy link

My tests contain the following mock :

    @MockkBean
    lateinit var myService: MyService

@MockkBean is from package import com.ninjasquad.springmockk.MockkBean

When i run ./gradlew aotTestClasesses I am getting error:

Caused by: java.lang.IllegalArgumentException: Failed to generate code for '[MockkDefinition@72f855b9 name = [null], typeToMock = com.myApp.MyService, extraInterfaces = set[[empty]], clear = AFTER]' with type ?

It may be problem with mockkbean dependency but I am wondering if there is any workaround for this from spring/graalvm side?
Thanks
Spring boot 3.1.3

@spring-projects-issues spring-projects-issues added the status: waiting-for-triage An issue we've not yet triaged label Sep 20, 2023
@wilkinsona
Copy link
Member

Mockito isn't supported in native tests. Duplicates #32195.

@wilkinsona wilkinsona closed this as not planned Won't fix, can't repro, duplicate, stale Sep 20, 2023
@wilkinsona wilkinsona added status: duplicate A duplicate of another issue and removed status: waiting-for-triage An issue we've not yet triaged labels Sep 20, 2023
@wilkinsona
Copy link
Member

Sorry, I misread @MockkBean as @MockBean.

There's no way for us to work around Mockk not supporting AOT and native. This will have to be addressed in Mockk.

@wilkinsona wilkinsona added status: invalid An issue that we don't feel is valid for: external-project For an external project and not something we can fix and removed status: duplicate A duplicate of another issue labels Sep 20, 2023
@hadson172
Copy link
Author

hadson172 commented Sep 20, 2023

@wilkinsona Any advices how to handle mocking beans in tests on graalvm ? Thanks

@wilkinsona
Copy link
Member

Personally, I wouldn't run tests that require mocking in a native image as I think the benefits are minimal at best and are outweighed by the time that it takes to build the image. If you want to test a native image, I would build the main native image and then exercise it with an approach that's closer to end-to-end testing.

If you have any further questions, please follow up on Stack Overflow or Gitter. As mentioned in the guidelines for contributing, we prefer to use GitHub issues only for bugs and enhancements.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
for: external-project For an external project and not something we can fix status: invalid An issue that we don't feel is valid
Projects
None yet
Development

No branches or pull requests

3 participants