diff --git a/build.gradle.kts b/build.gradle.kts index 91833ee1..c6e8cc1e 100644 --- a/build.gradle.kts +++ b/build.gradle.kts @@ -69,6 +69,9 @@ dependencies { testFramework(TestFrameworkType.Bundled) } + testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.8.1") + testRuntimeOnly("org.junit.vintage:junit-vintage-engine:5.8.1") + implementation(libs.bundles.junixsocket) implementation(libs.lsp4j) testImplementation("org.jetbrains.kotlin:kotlin-test-junit") @@ -123,6 +126,10 @@ tasks { defaultCharacterEncoding = "UTF-8" } + withType { + useJUnitPlatform() + } + withType { dependsOn(generateLexer, generateParser) diff --git a/gradle/libs.versions.toml b/gradle/libs.versions.toml index 3c3606c2..7763ac85 100644 --- a/gradle/libs.versions.toml +++ b/gradle/libs.versions.toml @@ -4,7 +4,7 @@ intellijPreview = "242.20224-EAP-CANDIDATE-SNAPSHOT" junixsocket = "2.10.0" [libraries] -junit = "junit:junit:4.13.2" +junit = "org.junit.jupiter:junit-jupiter-api:5.10.3" junixsocket-common = { module = "com.kohlschutter.junixsocket:junixsocket-common", version.ref = "junixsocket" } junixsocket-native-common = { module = "com.kohlschutter.junixsocket:junixsocket-native-common", version.ref = "junixsocket" } lsp4j = "org.eclipse.lsp4j:org.eclipse.lsp4j:0.23.1" diff --git a/src/test/kotlin/com/intellij/plugin/powershell/ide/run/PowerShellRunConfigurationTests.kt b/src/test/kotlin/com/intellij/plugin/powershell/ide/run/PowerShellRunConfigurationTests.kt index e567dcd5..a91f7a80 100644 --- a/src/test/kotlin/com/intellij/plugin/powershell/ide/run/PowerShellRunConfigurationTests.kt +++ b/src/test/kotlin/com/intellij/plugin/powershell/ide/run/PowerShellRunConfigurationTests.kt @@ -5,38 +5,53 @@ import com.intellij.execution.impl.RunManagerImpl import com.intellij.execution.impl.RunnerAndConfigurationSettingsImpl import com.intellij.execution.runners.ExecutionEnvironment import com.intellij.execution.runners.ProgramRunner -import com.intellij.testFramework.fixtures.BasePlatformTestCase +import com.intellij.openapi.project.Project +import com.intellij.testFramework.junit5.TestApplication +import com.intellij.testFramework.junit5.fixture.projectFixture import kotlinx.coroutines.runBlocking +import org.junit.jupiter.api.Assertions.assertEquals +import org.junit.jupiter.api.Test import java.nio.file.Path import kotlin.io.path.Path -class PowerShellRunConfigurationTests : BasePlatformTestCase() { +@TestApplication +class PowerShellRunConfigurationTests { + private val projectFixture = projectFixture() + + private val project: Project + get() = projectFixture.get() private val projectPath: Path get() = Path(project.basePath!!) private val defaultWorkingDirectory get() = projectPath.resolve("scripts") + @Test fun testCustomWorkingDirectoryPath() { val customDir = projectPath.resolve("ttt") assertWorkingDirectory(custom = customDir.toString(), expected = customDir) } + @Test fun testNoCustomWorkingDirectory() { assertWorkingDirectory(custom = null, expected = defaultWorkingDirectory) } + @Test fun testEmptyCustomWorkingDirectory() { assertWorkingDirectory(custom = "", expected = defaultWorkingDirectory) } + @Test fun testCustomWorkingDirectoryPathVariable() { assertWorkingDirectory(custom = "\$PROJECT_DIR$/foobar", expected = projectPath.resolve("foobar")) } + @Test fun testInvalidWorkingDir() { assertWorkingDirectory(custom = invalidPath, expected = defaultWorkingDirectory) } + @Test fun testInvalidScriptPath() { assertWorkingDirectory(custom = null, scriptPath = invalidPath, expected = Path(System.getProperty("user.home"))) }