eeverman / eeverman/andhow

Simplify unit testing w/ different property values

Open
#736 2 comments 0 reactions 0 assignees View on GitHub
API Addition enhancement
Dominant language
Java
Stars
25
Forks
34
PR merge metrics
No merged PRs in 30d

Description

**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.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.