github instancio/instancio instancio-parent-2.6.0
2.6.0

What's Changed

New Features

  • Experimental feature: new shorthand API provided by Gen class for generating simple value types.
    Values generated using this API are reproducible when used InstancioExtension.
import static org.instancio.Gen.*;

ZonedDateTime zdt = temporal().zonedDateTime().future().get();

List<String> strings = string().prefix("foo-").alphaNumeric().list(10);

Stream<Integer> stream = ints().range(0, 100).stream();

String yesOrNo = booleans().map(b -> b ? "yes" : "no");
  • Experimental feature: new top-level API method generate(TargetSelector selector, GeneratorSpec<V> spec)
    This methods accepts generators provided by the Gen described above.
Address address = Instancio.of(Address.class)
        .generate(field(Phone::getCountryCode), Gen.string().digits().prefix("+").length(1, 2))
        .create();

Enhancements

  • @InstancioSource no longer requires classes to be specified in the annotation.
    The values attribute of the annotation has been marked as deprecated and will be removed in version 3.0.0

Before:

@InstancioSource(Foo.class, Bar.class)
@ParameterizedTest
void example(Foo foo, Bar bar) {
    // ...
}

Now:

@InstancioSource
@ParameterizedTest
void example(Foo foo, Bar bar) {
    // ...
}

  • Resolve @ParameterizedTest argument types from the test method. by @armandino in #361
  • Updated test dependencies by @armandino in #362
  • Reverted Mockito from 5.0.0 to 4.8.0 due to build failure by @armandino in #363
  • Minor refactoring/cleanup by @armandino in #364
  • Updated return type to hide the generate() method from public API. by @armandino in #365
  • Fixed generator mismatch error message for enums + tests/cleanup. by @armandino in #366
  • Shorthand API for generating simple values. by @armandino in #367

Full Changelog: instancio-parent-2.5.0...instancio-parent-2.6.0

Don't miss a new instancio release

NewReleases is sending notifications on new releases.