diff --git a/testlib/src/test/java/com/diffplug/spotless/scala/ScalaFmtStepTest.java b/testlib/src/test/java/com/diffplug/spotless/scala/ScalaFmtStepTest.java index 8003607962..bad573e985 100644 --- a/testlib/src/test/java/com/diffplug/spotless/scala/ScalaFmtStepTest.java +++ b/testlib/src/test/java/com/diffplug/spotless/scala/ScalaFmtStepTest.java @@ -20,7 +20,7 @@ import java.io.File; import java.io.IOException; -import java.util.NoSuchElementException; +import java.lang.reflect.InvocationTargetException; import org.junit.jupiter.api.Test; @@ -91,10 +91,8 @@ void invalidConfiguration() throws Exception { File invalidConfFile = createTestFile("scala/scalafmt/scalafmt.invalid.conf"); Provisioner provisioner = TestProvisioner.mavenCentral(); - NoSuchElementException exception; - - exception = assertThrows(NoSuchElementException.class, + InvocationTargetException exception = assertThrows(InvocationTargetException.class, () -> StepHarness.forStep(ScalaFmtStep.create("3.0.0", provisioner, invalidConfFile)).test("", "")); - assertThat(exception.getMessage()).contains("found option 'invalidScalaFmtConfigField' which wasn't expected"); + assertThat(exception.getCause().getMessage()).contains("found option 'invalidScalaFmtConfigField' which wasn't expected"); } }