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

Mocking fails in a test method containing space in its name #443

Open
MastaP opened this issue Sep 16, 2021 · 0 comments
Open

Mocking fails in a test method containing space in its name #443

MastaP opened this issue Sep 16, 2021 · 0 comments

Comments

@MastaP
Copy link

MastaP commented Sep 16, 2021

Another bug has emerged while working on #441
The following two methods have identical bodies, the only difference is in test methods' names, the second one contains a space

    @Test
    fun test() {
        val deferredSupplier = spy(java.util.function.Supplier { Flux.empty<String>() })
        Flux.defer(deferredSupplier).blockLast()
        verify(deferredSupplier, times(1)).get()
    }

    @Test
    fun `test spy`() {
        val deferredSupplier = spy(java.util.function.Supplier { Flux.empty<String>() })
        Flux.defer(deferredSupplier).blockLast()
        verify(deferredSupplier, times(1)).get()
    }

The error message is:

Mockito cannot mock this class: class com.example.Test$test spy$deferredSupplier$1.
Can not mock final classes with the following settings :
 - explicit serialization (e.g. withSettings().serializable())
 - extra interfaces (e.g. withSettings().extraInterfaces(...))

You are seeing this disclaimer because Mockito is configured to create inlined mocks.

See https://github.com/MastaP/mockito-kotlin15-bug/actions/runs/1241073434 for details
kotlin: 1.5.30
mockito-kotlin:3.2.0
mockito-inline:3.12.4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant