Skip to content

Mocking session scoped spy bean calls real method #17817

@cdalexndr

Description

@cdalexndr

Trying to mock a @SessionScope in a test by autowiring it using @SpyBean and then mocking using doReturn(..).when(sessionScopedBean).method(any()) calls the real method with null argument instead of silently registering mock.
Removing @SessionScope from the bean resolves this issue.

Spring boot 2.1.6.RELEASE

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions