Skip to content

Customizing property with private/protected setter #94

Description

@djkeh

Consider we have a class to create a fixture like this:

class MyClass {
    var name: String = "initial value"
        protected set
}

when we do:

kotlinFixture {
    property(MyClass::name) { "test" }
}

will throw an exception like this:

java.lang.UnsupportedOperationException: Unable to handle MyClass
Unable to resolve class MyClass
    Unable to populate class MyClass
    Unable to instantiate class MyClass using factory methods

    at com.appmattus.kotlinfixture.Fixture.create(KotlinFixture.kt:85)

because the proeprty name doesn't provide public setter.
How do I customize that field?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions