11[ ![ Tests] ( https://github.com/Nylle/JavaFixture/workflows/test/badge.svg?branch=master )] ( https://github.com/Nylle/JavaFixture/actions?query=workflow%3ATest )
2- [ ![ Maven Central] ( https://img.shields.io/maven-central/v/com.github.nylle/javafixture.svg?label=maven-central )] ( http ://search. maven.org/#artifactdetails| com.github.nylle| javafixture|2.2.0| )
2+ [ ![ Maven Central] ( https://img.shields.io/maven-central/v/com.github.nylle/javafixture.svg?label=maven-central )] ( https ://maven-badges.herokuapp.com/maven-central/ com.github.nylle/ javafixture)
33[ ![ MIT license] ( http://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat )] ( http://opensource.org/licenses/MIT )
44
55# JavaFixture
@@ -22,7 +22,7 @@ The purpose of this project is to generate full object graphs for use in test su
2222<dependency >
2323 <groupId >com.github.nylle</groupId >
2424 <artifactId >javafixture</artifactId >
25- <version >2.2 .0</version >
25+ <version >2.3 .0</version >
2626 <scope >test</scope >
2727</dependency >
2828```
@@ -71,7 +71,7 @@ ParentDto result = fixture.create(ParentDto.class);
7171List<String > result = fixture. createMany(String . class). collect(Collectors . toList());
7272```
7373#### Sample Result
74- ArrayList:
74+ ArrayList:
7575- String: "333af3f6-4ed1-4580-9cae-aaee271d7ba7"
7676- String: "9452541b-c6f9-4316-b254-28d00b327d0d"
7777- String: "4ed0f3c4-5ea3-4dbb-b31c-f92c036af463"
@@ -81,7 +81,7 @@ ArrayList:
8181List<String > result = fixture. build(String . class). createMany(4 ). collect(Collectors . toList());
8282```
8383#### Sample Result
84- ArrayList:
84+ ArrayList:
8585- String: "333af3f6-4ed1-4580-9cae-aaee271d7ba7"
8686- String: "9452541b-c6f9-4316-b254-28d00b327d0d"
8787- String: "4ed0f3c4-5ea3-4dbb-b31c-f92c036af463"
@@ -94,7 +94,7 @@ result.add("HELLO!");
9494fixture. addManyTo(result, String . class);
9595```
9696#### Sample Result
97- ArrayList:
97+ ArrayList:
9898- String: "HELLO!"
9999- String: "333af3f6-4ed1-4580-9cae-aaee271d7ba7"
100100- String: "9452541b-c6f9-4316-b254-28d00b327d0d"
@@ -263,18 +263,25 @@ All arguments of the test-method below will be provided as a random object gener
263263@TestWithFixture
264264void injectParameterViaMethodExtension(TestDto testObject, int intValue, Optional<String > genericObject) {
265265 assertThat(testObject). isInstanceOf(TestDto . class);
266-
266+
267267 assertThat(intValue). isBetween(Integer . MIN_VALUE , Integer . MAX_VALUE );
268-
268+
269269 assertThat(genericObject). isInstanceOf(Optional . class);
270270 assertThat(genericObject). isPresent();
271271 assertThat(genericObject. get()). isInstanceOf(String . class);
272272}
273273```
274-
274+ You can also configure Fixture inline:
275+ ``` java
276+ @TestWithFixture (minCollectionSize = 11 , maxCollectionSize = 11 , positiveNumbersOnly = true )
277+ void configurableFixture(List<Integer > input) {
278+ assertThat(input). hasSize(11 );
279+ assertThat(input). allMatch(x - > x > 1 );
280+ }
281+ ```
275282
276283### Parameterized Tests
277- For some syntactic sugar, this library comes with a wrapper for JUnit5's parameterized
284+ For some syntactic sugar, this library comes with a wrapper for JUnit5's parameterized
278285test feature, called ` @TestWithCases ` .
279286``` java
280287@TestWithCases
@@ -292,9 +299,9 @@ the test's arguments.
292299Due to Java's limited annotation design, the following rules apply:
293300- Values can only be of type ` String ` , ` Class ` or primitive like ` int ` , ` boolean ` , ` float ` ,
294301 etc.
295- - Annotation parameters are indexed and they must fit to the test method argument.
302+ - Annotation parameters are indexed and they must fit to the test method argument.
296303 _ Example:_ ` str1 = "foo" ` can only be applied to the first argument which must be of type
297304 ` String ` , while ` int2 = 3 ` can only be applied to the second argument which obviously must
298- be of type ` int ` and so on.
305+ be of type ` int ` and so on.
299306- The current implementation only supports up to 6 arguments per test method.
300307
0 commit comments