Skip to content

Enums not mocked when allopen plugin applied to class #132

@griffinsorrentino

Description

@griffinsorrentino

Hey @lupuuss thanks for your continued work!

Problem

Kotlin: 2.3.0
AGP: 9.0.0
Mokkery: 3.2.0

Similar to #122 and #78

When following the guide to mock a class, any enum fields on that class will not be mocked. When trying to access the field, a nullpointer is thrown.

Repro Steps

Take the given enum

enum class BrokenEnum {
   BROKEN
}

Take the given class (with your defined allopen annotation)

@Mockable
class BrokenMock(
   val someField: String,
   val enum: BrokenEnum
)

mock it, try to assert

val testMock = mock<BrokenMock>()
assertTrue {
    testMock.enum == BrokenEnum.BROKEN
}

I'm unsure if this is an issue with the allopen plugin or Mokkery. Removing the @Mockable (or similar) annotation and manually adding open to the class definition works without issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions