Annotation Interface EnableSetup


@Retention(RUNTIME) @Target(FIELD) public @interface EnableSetup
Marker annotation for TestEnvironmentSetup test fields declaration. Extra annotation required to remove uncertainty and apply some context (avoid questions why it works).

Example usage:

@EnableSetup static TestEnvironmentSetup EXT = ext -> {
  Something smth = new Something();
  smth.start()
  ext.configOverride("value", () -> smth.getValue());
  // assume Something implements Closable and so would be closed after test
  return smth;
 }

Field might be not static only if extension is registered in non-static field (application started for each test method), otherwise it must be static. Incorrect usage will be indicated with an exception.

Since:
14.05.2022
See Also: