Skip to content

Support Mockito with @MockBean and @SpyBean in AOT-processed tests #32195

Not planned
@philwebb

Description

@philwebb
Member

Currently Mockito doesn't work with native tests. See spring-attic/spring-native#1561 and spring-attic/spring-native#1063 for more details.

For now, we can disable the ResetMocksTestExecutionListener, but it would be nice if we could make Mockito work.

Activity

added this to the 3.x milestone on Aug 30, 2022
sdeleuze

sdeleuze commented on Aug 31, 2022

@sdeleuze
Contributor

FYI there is ongoing work on GraalVM side to make it work, I will try to share up to date news about current status.

added
theme: aotAn issue related to Ahead-of-time processing
and removed on Oct 17, 2022
mhalbritter

mhalbritter commented on Nov 25, 2022

@mhalbritter
Contributor

There's more than just GraalVM supporting this. Currently, using @MockBean wreaks havoc even when not using native-image, just enabling AOT mode is enough.

mhalbritter

mhalbritter commented on Nov 25, 2022

@mhalbritter
Contributor
mhalbritter

mhalbritter commented on Dec 5, 2022

@mhalbritter
Contributor

I've added metadata for Mockito 4.8.1 to the reachability-metadata repository. However I found no way to get the class mocks from Mockito working, as they all rely on creating classes at runtime. But it works when using the ProxyMockMaker, which is able to mock interfaces.

eiswind

eiswind commented on Dec 7, 2022

@eiswind

@mhalbritter are there plans to support @MockBean? Having this with the proxymockmaker would be already a big gain.

removed this from the 3.x milestone on Dec 8, 2022

31 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    for: external-projectFor an external project and not something we can fixstatus: supersededAn issue that has been superseded by anothertheme: aotAn issue related to Ahead-of-time processingtype: enhancementA general enhancement

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @sbrannen@sdeleuze@philwebb@wilkinsona@eiswind

        Issue actions

          Support Mockito with @MockBean and @SpyBean in AOT-processed tests · Issue #32195 · spring-projects/spring-boot