Skip to content

Child class non-empty constructors not found #113

Open
@tikal

Description

@tikal

I was using fixtures with a class with final fields and constructors only, without issue.
I had to change this class to an abstract class eventually, but fixtures were not working on the subclasses, throwing Could not find constructor with args [] on class on the child class.
While there was no need for an empty constructor on the parent class.

Workaround: add an empty constructor on the parent class, override it with a private constructor on the child class.

public abstract class Transaction<T, U> {
    private final String transactionId;

   ...

    // Needed this to support fixtures
    TransactionHistory() {
        this(null);
    }

    TransactionHistory(final String transactionId) {
        this(transactionId);
    }
}

public class ChargeTransaction extends Transaction<ChargeRequest, ChargeResponse> {
    private ChargeTransaction() {
    }
}

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