Skip to content

Add support for testing #7

@ShaishavGandhi

Description

@ShaishavGandhi

Extension functions are treated as static functions when you're testing them with Mockito or any other framework. This means that Mockito will fail you when you try to verify method invocations on the wrapper.

Unfortunately, PowerMockito doesn't help either. From the digging I did, the way you do it with PowerMockito is:

mockStatic(CustomWrapper::class.java)
// The following code is the problem. Since extension functions aren't static, this 
// actually won't compile.
`when`(CustomWrapper.getCustomAttribute()).thenReturn()

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions