Skip to content

Commit

Permalink
Add one more test to cover LogbackTestHelper#resetLogback with fallback
Browse files Browse the repository at this point in the history
This method is mocked in other tests, so is never exercised.
Test the delegation to LogbackTestHelpers by passing arguments
that don't exist, and validating the exception we get. Kind
of invasive but gets the job done without actually resetting
Logback, which we generally want to avoid.
  • Loading branch information
sleberknight committed Feb 9, 2024
1 parent 935f7c9 commit f0822ab
Showing 1 changed file with 12 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.kiwiproject.test.logback;

import static org.assertj.core.api.Assertions.assertThatIllegalArgumentException;
import static org.mockito.ArgumentMatchers.anyString;
import static org.mockito.Mockito.doNothing;
import static org.mockito.Mockito.spy;
Expand Down Expand Up @@ -39,4 +40,15 @@ void shouldUseDefaultWhenCustomConfigurationIsBlank(String configFile) {

verify(helper).resetLogback();
}

@Test
void shouldDelegateToLogbackTestHelpersWithFallback() {
// Verify the delegation without actually resetting Logback
// by passing in config files that don't exist.

assertThatIllegalArgumentException()
.isThrownBy(() ->
new LogbackTestHelper().resetLogback("acme-test-logback.xml", "acme-logback.xml"))
.withMessage("Did not find any of the Logback configurations: [acme-test-logback.xml, acme-logback.xml]");
}
}

0 comments on commit f0822ab

Please sign in to comment.