-
Notifications
You must be signed in to change notification settings - Fork 25
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Running tests from a custom compilation uses wrong Gradle task for tests #266
Comments
This is where plugin looks for JVM test tasks: kotest-intellij-plugin/src/main/kotlin/io/kotest/plugin/intellij/toolwindow/treeModel.kt Line 59 in 8b7fdab
What would be the most sensible approach here to make it pick up test tasks from other compilations? |
As a workaround, created this task that automatically generates a run configuration for each integration test file: /**
* Generate runner configuration for JVM Integration tests manually, until Kotest plugin
* supports running tests from custom test compilations: https://github.com/kotest/kotest-intellij-plugin/issues/266.
*/
private fun Project.generateJvmIntegrationTestRunConfiguration() {
val runConfigurationsDir = rootDir.resolve(".idea/runConfigurations")
runConfigurationsDir.mkdirs()
val integrationTestDir = projectDir.resolve("src/jvmIntegrationTest/kotlin")
if (integrationTestDir.exists()) {
// Generate run configuration for each integration test file, if any:
val testFiles = integrationTestDir.walk().filter {
it.isFile && it.name.endsWith("Tests.kt")
}
testFiles.forEach { file ->
println("Generating run configuration for $file")
val configName = file.nameWithoutExtension
val fullyQualifiedName =
file.toRelativeString(integrationTestDir).replace("/", ".").removeSuffix(".kt")
val runConfigurationXml = """
<component name="ProjectRunConfigurationManager">
<configuration default="false" name="$configName" type="GradleRunConfiguration" factoryName="Gradle">
<ExternalSystemSettings>
<option name="executionName" />
<option name="externalProjectPath" value="${"$"}PROJECT_DIR$" />
<option name="externalSystemIdString" value="GRADLE" />
<option name="scriptParameters" value="" />
<option name="taskDescriptions">
<list />
</option>
<option name="taskNames">
<list>
<option value="${project.path}:jvmIntegrationTest" />
<option value="--tests" />
<option value=""$fullyQualifiedName"" />
</list>
</option>
<option name="vmOptions" />
</ExternalSystemSettings>
<ExternalSystemDebugServerProcess>false</ExternalSystemDebugServerProcess>
<ExternalSystemReattachDebugProcess>true</ExternalSystemReattachDebugProcess>
<DebugAllEnabled>false</DebugAllEnabled>
<ForceTestExec>true</ForceTestExec>
<method v="2" />
</configuration>
</component>
""".trimIndent()
val runConfigurationFile = runConfigurationsDir.resolve("$configName.xml")
println("Generating into $runConfigurationFile")
runConfigurationFile.writeText(runConfigurationXml)
}
}
} |
We need a way to determine if a module is a test module or not, programatically, rather than using the string names. |
I have a custom
integrationTest
compilation in KMP project and a JVM target. I’ve got some tests injvmIntegrationTest
source set. When trying to run these tests from IDE using Kotest plugin, it runscleanJvmTest
andjvmTest
tasks, I would expect it to runcleanJvmIntegrationTest
andjvmIntegrationTest
tasks.Is it something that Kotest plugin need to somehow pick up on, or are there additional steps I need to take when configuring my compilation?
Here's how I configure
integrationTest
compilation for my JVM target:The text was updated successfully, but these errors were encountered: