diff --git a/core/pom.xml b/core/pom.xml index 7985e06e..7626ebf6 100644 --- a/core/pom.xml +++ b/core/pom.xml @@ -151,6 +151,11 @@ kotlin-stdlib-jdk7 ${kotlin.version} + + org.jetbrains.kotlin + kotlin-test + ${kotlin.version} + org.jetbrains.kotlin kotlin-compiler-embeddable diff --git a/core/src/test/java/com/facebook/ktfmt/cli/ParsedArgsTest.kt b/core/src/test/java/com/facebook/ktfmt/cli/ParsedArgsTest.kt index 63d4c2f1..40f36461 100644 --- a/core/src/test/java/com/facebook/ktfmt/cli/ParsedArgsTest.kt +++ b/core/src/test/java/com/facebook/ktfmt/cli/ParsedArgsTest.kt @@ -22,7 +22,8 @@ import com.google.common.truth.Truth.assertThat import java.io.ByteArrayOutputStream import java.io.FileNotFoundException import java.io.PrintStream -import junit.framework.Assert.fail +import kotlin.io.path.createTempDirectory +import kotlin.test.assertFailsWith import org.junit.After import org.junit.Test import org.junit.runner.RunWith @@ -32,7 +33,7 @@ import org.junit.runners.JUnit4 @RunWith(JUnit4::class) class ParsedArgsTest { - private val root = createTempDir() + private val root = createTempDirectory().toFile() @After fun tearDown() { @@ -132,12 +133,11 @@ class ParsedArgsTest { fun `processArgs use the @file option with non existing file`() { val out = ByteArrayOutputStream() - try { - ParsedArgs.processArgs(PrintStream(out), arrayOf("@non-existing-file")) - fail("expected an exception of type FileNotFoundException but nothing was thrown") - } catch (e: FileNotFoundException) { - assertThat(e.message).contains("non-existing-file (No such file or directory)") - } + val e = + assertFailsWith { + ParsedArgs.processArgs(PrintStream(out), arrayOf("@non-existing-file")) + } + assertThat(e.message).contains("non-existing-file (No such file or directory)") } @Test