Skip to content

support for heterogeneous arbitrary configurators in base #493

Description

@SimY4

Testing Problem

The current implementation of ArbitraryConfiguratorBase makes it super easy to configure a single arbitrary type using multiple annotation types but not vice versa where you might want to configure multiple arbitraries with a single annotation. i.e.

Suppose I have two arbitraries: Arbitrary<Foo> and Arbitrary<Bar> as I have a single annotation rule that can be applied to both. Unfortunately, due to erasure, there's no way to define two configure methods in base to satisfy its current contract:

class FooBarConfigurator extends ArbitraryConfiguratorBase {
  Arbitrary<Foo> configure(Arbitrary<Foo> arb, SomeAnnotation ann) { return arb; }

  Arbitrary<Bar> configure(Arbitrary<Bar> arb, SomeAnnotation ann) { return arb; } // no good since signatures collide
}

Suggested Solution

I would be keen to explore if jqwik could expand its search for potential config method signatures to include methods with random postfixes. i.e. say this would still be picked up by base as valid:

class FooBarConfigurator extends ArbitraryConfiguratorBase {
  Arbitrary<Foo> configureFoo(Arbitrary<Foo> arb, SomeAnnotation ann) { return arb; }

  Arbitrary<Bar> configureBar(Arbitrary<Bar> arb, SomeAnnotation ann) { return arb; }
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Fields

    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