Skip to content

Simplify unit testing w/ different property values #736

@eeverman

Description

@eeverman

Is your feature request related to a problem? Please describe.
Setting up JUnit tests is still somewhat verbose:

@KillAndHowBeforeThisTest
@Test
public void myTest() {
  AndHow.findConfig().setClasspathFilePath("/some/path/to/a/file.properties);
}

Describe the solution you'd like
Create some dedicated test annotations that accept properties files as arguments:

@ReloadAndHowFromClasspathProperties(path="/some/path/to/a/file.properties");
@Test
public void myTest() {
  // Test uses AndHow loaded from the prop file (but still uses any discovered AndHow init classes)
}

@ReloadAndHowFromClasspathPropertiesOnly(path="/some/path/to/a/file2.properties");
@Test
public void myTest2() {
  // Test uses AndHow loaded from the prop file (skipping any AndHow init classes)
}

These annotations could be applied to either test classes or individual test methods. The 'Only' method could also shut down the other loaders, perhaps other than the fixedValue loader to allow tests to override individual values.

Describe alternatives you've considered
Method naming could use some consideration.

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions