Annotation Type WithSettings


@Documented @Target(FIELD) @Retention(RUNTIME) public @interface WithSettings
An annotation for supplying custom settings to a unit test class.

This annotation must be placed on a Settings field. There can be at most one field annotated @WithSettings per test class.


 @ExtendWith(InstancioExtension.class)
 class ExampleTest {
     @WithSettings
     private final Settings settings = Settings.create()
         .set(Keys.COLLECTION_MIN_SIZE, 50)
         .set(Keys.COLLECTION_MAX_SIZE, 100);

     @Test
     void example() {

     }
 }
 

Note: when a Settings instance is annotated with @WithSettings, the specified settings are not automatically applied to Nested test classes.

Since:
1.1.1