Skip to content

Unable to mock Map[String, String] #236

@diegoboston

Description

@diegoboston

I'm using IdiomaticMockito in my test.

val mocked = mock[Map[String, String]]
mocked.apply(*) shouldReturn "123"
mocked("key") should equal("123")
mocked.apply(*) wasCalled once

This fails at run-time as shown below. A workaround is:

    abstract class TestMap extends Map[String, String]
    val mocked = mock[TestMap]

Note that the first example works fine with regular Mockito.

The failure:

                There was 1 failure:
                 1) initializationError(<MYTESTPATH>)
                 java.lang.StackOverflowError
                 	at ru.vyarus.java.generics.resolver.util.GenericsResolutionUtils.resolveGenerics(GenericsResolutionUtils.java:92)
                 	at ru.vyarus.java.generics.resolver.util.walk.TypesWalker.visitGenerics(TypesWalker.java:120)
                   ....

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions