AT-3511: initial commit for sample test with fixtures

not yet working

GitOrigin-RevId: 449ae4455b2412b838a5575c842e72c9251d4026
This commit is contained in:
Anastasia Katsman
2025-11-18 00:22:41 +00:00
committed by intellij-monorepo-bot
parent 835e1de895
commit e835485f62
15 changed files with 352 additions and 1 deletions
+2
View File
@@ -812,6 +812,8 @@
<module fileurl="file://$PROJECT_DIR$/plugins/laf/win10/intellij.laf.win10.iml" filepath="$PROJECT_DIR$/plugins/laf/win10/intellij.laf.win10.iml" />
<module fileurl="file://$PROJECT_DIR$/tools/intellij.lambda.sampleTests/intellij.lambda.sampleTests.iml" filepath="$PROJECT_DIR$/tools/intellij.lambda.sampleTests/intellij.lambda.sampleTests.iml" />
<module fileurl="file://$PROJECT_DIR$/tools/intellij.lambda.sampleTests/plugin/intellij.lambda.sampleTests.plugin.iml" filepath="$PROJECT_DIR$/tools/intellij.lambda.sampleTests/plugin/intellij.lambda.sampleTests.plugin.iml" />
<module fileurl="file://$PROJECT_DIR$/tools/intellij.lambda.sampleTestsWithFixtures/intellij.lambda.sampleTestsWithFixtures.iml" filepath="$PROJECT_DIR$/tools/intellij.lambda.sampleTestsWithFixtures/intellij.lambda.sampleTestsWithFixtures.iml" />
<module fileurl="file://$PROJECT_DIR$/tools/intellij.lambda.sampleTestsWithFixtures/plugin/intellij.lambda.sampleTestsWithFixtures.plugin.iml" filepath="$PROJECT_DIR$/tools/intellij.lambda.sampleTestsWithFixtures/plugin/intellij.lambda.sampleTestsWithFixtures.plugin.iml" />
<module fileurl="file://$PROJECT_DIR$/tools/intellij.lambda.testFramework/plugin/intellij.lambda.test.plugin.iml" filepath="$PROJECT_DIR$/tools/intellij.lambda.testFramework/plugin/intellij.lambda.test.plugin.iml" />
<module fileurl="file://$PROJECT_DIR$/tools/intellij.lambda.testFramework/intellij.lambda.testFramework.iml" filepath="$PROJECT_DIR$/tools/intellij.lambda.testFramework/intellij.lambda.testFramework.iml" />
<module fileurl="file://$PROJECT_DIR$/libraries/aalto-xml/intellij.libraries.aalto.xml.iml" filepath="$PROJECT_DIR$/libraries/aalto-xml/intellij.libraries.aalto.xml.iml" />
+2
View File
@@ -1495,6 +1495,8 @@ tools/devLauncher
tools/devLauncher/tests
tools/intellij.lambda.sampleTests
tools/intellij.lambda.sampleTests/plugin
tools/intellij.lambda.sampleTestsWithFixtures
tools/intellij.lambda.sampleTestsWithFixtures/plugin
tools/intellij.lambda.testFramework
tools/intellij.lambda.testFramework/plugin
tools/intellij.tools.ide.metrics.benchmark
@@ -1,11 +1,18 @@
### auto-generated section `build intellij.platform.testFramework.junit5.codeInsight` start
load("@rules_jvm//:jvm.bzl", "jvm_library")
load("@rules_jvm//:jvm.bzl", "jvm_library", "resourcegroup")
resourcegroup(
name = "codeInsight_resources",
srcs = glob(["resources/**/*"]),
strip_prefix = "resources"
)
jvm_library(
name = "codeInsight",
module_name = "intellij.platform.testFramework.junit5.codeInsight",
visibility = ["//visibility:public"],
srcs = glob(["src/**/*.kt", "src/**/*.java", "src/**/*.form"], allow_empty = True),
resources = [":codeInsight_resources"],
deps = [
"//platform/testFramework",
"//platform/testFramework/junit5",
@@ -3,6 +3,7 @@
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-resource" />
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" packagePrefix="com.intellij.platform.testFramework.junit5.codeInsight" />
</content>
<orderEntry type="inheritedJdk" />
@@ -0,0 +1,5 @@
<idea-plugin>
<dependencies>
<module name="intellij.platform.testFramework.junit5"/>
</dependencies>
</idea-plugin>
@@ -0,0 +1,80 @@
### auto-generated section `build intellij.lambda.sampleTestsWithFixtures` start
load("//build:compiler-options.bzl", "create_kotlinc_options")
load("@rules_jvm//:jvm.bzl", "jvm_library", "resourcegroup")
create_kotlinc_options(
name = "custom_lambda-sampleTestsWithFixtures",
x_context_parameters = True
)
resourcegroup(
name = "lambda-sampleTestsWithFixtures_test_resources",
srcs = glob(["resources/**/*"]),
strip_prefix = "resources"
)
jvm_library(
name = "lambda-sampleTestsWithFixtures_test_lib",
module_name = "intellij.lambda.sampleTestsWithFixtures",
visibility = ["//visibility:public"],
srcs = glob(["tests/**/*.kt", "tests/**/*.java", "tests/**/*.form"], allow_empty = True),
resources = [":lambda-sampleTestsWithFixtures_test_resources"],
kotlinc_opts = ":custom_lambda-sampleTestsWithFixtures",
deps = [
"@lib//:kodein-di-jvm",
"@lib//:kotlin-stdlib",
"@lib//:kotlin-test",
"@lib//:assert_j",
"@lib//:rd-framework",
"@lib//:rd-core",
"//libraries/kotlin/reflect",
"//tools/intellij.tools.ide.starter:ide-starter",
"//tools/intellij.tools.ide.starter.junit5:ide-starter-junit5",
"//tools/intellij.tools.ide.starter.junit5:ide-starter-junit5_test_lib",
"//tools/intellij.tools.ide.starter.driver:ide-starter-driver",
"//tools/intellij.tools.ide.starter.build.server:ide-starter-build-server",
"//platform/core-api:core",
"//platform/core-impl",
"//platform/core-ui",
"//platform/lang-api:lang",
"//platform/lang-impl",
"//platform/platform-api:ide",
"//platform/editor-ui-api:editor-ui",
"//platform/editor-ui-ex:editor-ex",
"//platform/testFramework/junit5",
"//platform/testFramework/junit5:junit5_test_lib",
"//platform/code-style-api:codeStyle",
"//platform/execution-impl",
"//platform/platform-impl:ide-impl",
"//platform/platform-impl:ide-impl_test_lib",
"//platform/remoteDev-util",
"//platform/remoteDev-util:remoteDev-util_test_lib",
"//platform/analysis-api:analysis",
"//plugins/performanceTesting/core:performanceTesting",
"//plugins/performanceTesting/core:performanceTesting_test_lib",
"//platform/platform-impl/codeinsight-inline:ide-codeinsight-inline",
"//platform/xdebugger-api:debugger",
"//platform/xdebugger-impl:debugger-impl",
"//platform/xdebugger-impl:debugger-impl_test_lib",
"//platform/util/concurrency",
"//platform/util/concurrency:concurrency_test_lib",
"//platform/usageView",
"//tools/intellij.lambda.testFramework:lambda-testFramework",
"//libraries/junit5",
"//libraries/junit5-launcher",
"//libraries/junit5-params",
"//libraries/junit5-pioneer",
"//platform/testFramework",
"//platform/testFramework:testFramework_test_lib",
]
)
### auto-generated section `build intellij.lambda.sampleTestsWithFixtures` end
### auto-generated section `test intellij.lambda.sampleTestsWithFixtures` start
load("@community//build:tests-options.bzl", "jps_test")
jps_test(
name = "lambda-sampleTestsWithFixtures_test",
runtime_deps = [":lambda-sampleTestsWithFixtures_test_lib"]
)
### auto-generated section `test intellij.lambda.sampleTestsWithFixtures` end
@@ -0,0 +1,65 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="FacetManager">
<facet type="kotlin-language" name="Kotlin">
<configuration version="5" platform="JVM 21" allPlatforms="JVM [21]" useProjectSettings="false">
<compilerSettings>
<option name="additionalArguments" value="-Xjvm-default=all -XXLanguage:+AllowEagerSupertypeAccessibilityChecks -opt-in=com.intellij.openapi.util.IntellijInternalApi -Xcontext-parameters" />
</compilerSettings>
<compilerArguments>
<stringArguments>
<stringArg name="jvmTarget" arg="21" />
<stringArg name="apiVersion" arg="2.2" />
<stringArg name="languageVersion" arg="2.2" />
</stringArguments>
</compilerArguments>
</configuration>
</facet>
</component>
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/resources" type="java-test-resource" />
<sourceFolder url="file://$MODULE_DIR$/tests" isTestSource="true" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
<orderEntry type="library" scope="TEST" name="kodein-di-jvm" level="project" />
<orderEntry type="library" scope="TEST" name="kotlin-stdlib" level="project" />
<orderEntry type="library" scope="TEST" name="kotlin-test" level="project" />
<orderEntry type="library" scope="TEST" name="assertJ" level="project" />
<orderEntry type="library" scope="TEST" name="rd-framework" level="project" />
<orderEntry type="library" scope="TEST" name="rd-core" level="project" />
<orderEntry type="module" module-name="intellij.libraries.kotlin.reflect" scope="TEST" />
<orderEntry type="module" module-name="intellij.tools.ide.starter" scope="TEST" />
<orderEntry type="module" module-name="intellij.tools.ide.starter.junit5" scope="TEST" />
<orderEntry type="module" module-name="intellij.tools.ide.starter.driver" scope="TEST" />
<orderEntry type="module" module-name="intellij.tools.ide.starter.build.server" scope="TEST" />
<orderEntry type="module" module-name="intellij.platform.core" scope="TEST" />
<orderEntry type="module" module-name="intellij.platform.core.impl" scope="TEST" />
<orderEntry type="module" module-name="intellij.platform.core.ui" scope="TEST" />
<orderEntry type="module" module-name="intellij.platform.lang" scope="TEST" />
<orderEntry type="module" module-name="intellij.platform.lang.impl" scope="TEST" />
<orderEntry type="module" module-name="intellij.platform.ide" scope="TEST" />
<orderEntry type="module" module-name="intellij.platform.editor.ui" scope="TEST" />
<orderEntry type="module" module-name="intellij.platform.editor.ex" scope="TEST" />
<orderEntry type="module" module-name="intellij.platform.testFramework.junit5" scope="TEST" />
<orderEntry type="module" module-name="intellij.platform.codeStyle" scope="TEST" />
<orderEntry type="module" module-name="intellij.platform.execution.impl" scope="TEST" />
<orderEntry type="module" module-name="intellij.platform.ide.impl" scope="TEST" />
<orderEntry type="module" module-name="intellij.remoteDev.util" scope="TEST" />
<orderEntry type="module" module-name="intellij.platform.analysis" scope="TEST" />
<orderEntry type="module" module-name="intellij.performanceTesting" scope="TEST" />
<orderEntry type="module" module-name="intellij.platform.ide.codeinsight.inline" scope="TEST" />
<orderEntry type="module" module-name="intellij.platform.debugger" scope="TEST" />
<orderEntry type="module" module-name="intellij.platform.debugger.impl" scope="TEST" />
<orderEntry type="module" module-name="intellij.platform.concurrency" scope="TEST" />
<orderEntry type="module" module-name="intellij.platform.usageView" scope="TEST" />
<orderEntry type="module" module-name="intellij.lambda.testFramework" scope="TEST" />
<orderEntry type="module" module-name="intellij.libraries.junit5" scope="TEST" />
<orderEntry type="module" module-name="intellij.libraries.junit5.launcher" scope="TEST" />
<orderEntry type="module" module-name="intellij.libraries.junit5.params" scope="TEST" />
<orderEntry type="module" module-name="intellij.libraries.junit5.pioneer" scope="TEST" />
<orderEntry type="module" module-name="intellij.platform.testFramework" scope="TEST" />
</component>
</module>
@@ -0,0 +1,17 @@
### auto-generated section `build intellij.lambda.sampleTestsWithFixtures.plugin` start
load("@rules_jvm//:jvm.bzl", "jvm_library", "resourcegroup")
resourcegroup(
name = "plugin_test_resources",
srcs = glob(["testResources/**/*"]),
strip_prefix = "testResources"
)
jvm_library(
name = "plugin_test_lib",
module_name = "intellij.lambda.sampleTestsWithFixtures.plugin",
visibility = ["//visibility:public"],
srcs = glob([], allow_empty = True),
resources = [":plugin_test_resources"]
)
### auto-generated section `build intellij.lambda.sampleTestsWithFixtures.plugin` end
@@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<module type="JAVA_MODULE" version="4">
<component name="NewModuleRootManager" inherit-compiler-output="true">
<exclude-output />
<content url="file://$MODULE_DIR$">
<sourceFolder url="file://$MODULE_DIR$/testResources" type="java-test-resource" />
</content>
<orderEntry type="inheritedJdk" />
<orderEntry type="sourceFolder" forTests="false" />
</component>
</module>
@@ -0,0 +1,28 @@
<idea-plugin>
<id>com.intellij.lambda.sampleTestsWithFixtures.plugin</id>
<vendor>JetBrains</vendor>
<content namespace="jetbrains">
<module name="intellij.platform.testFramework"/>
<module name="intellij.platform.testFramework.junit5.codeInsight"/>
<module name="intellij.platform.testFramework.junit5"/>
<module name="intellij.platform.testFramework.core"/>
<module name="intellij.platform.testFramework.common"/>
<module name="intellij.platform.testFramework.impl"/>
<module name="intellij.lambda.sampleTestsWithFixtures._test"/>
<module name="intellij.java.rt"/>
<module name="intellij.libraries.junit4"/>
<module name="intellij.libraries.junit5"/>
<module name="intellij.libraries.junit5.vintage"/>
<module name="intellij.libraries.junit5.launcher"/>
<module name="intellij.libraries.hamcrest"/>
<module name="intellij.tools.testsBootstrap"/>
</content>
<dependencies>
<module name="intellij.lambda.testFramework"/>
</dependencies>
</idea-plugin>
@@ -0,0 +1 @@
com.intellij.lambda.sampleTestsWithFixtures.util.SetLambdaPluginCallback
@@ -0,0 +1,34 @@
<idea-plugin>
<dependencies>
<module name="intellij.java.rt"/>
<module name="intellij.tools.testsBootstrap" />
<module name="intellij.libraries.hamcrest"/>
<module name="intellij.libraries.junit4"/>
<module name="intellij.libraries.junit5.vintage"/>
<module name="intellij.libraries.junit5.launcher"/>
<module name="intellij.platform.testFramework"/>
<module name="intellij.platform.testFramework.junit5.codeInsight"/>
<module name="intellij.platform.testFramework.impl"/>
<module name="intellij.platform.testFramework.junit5"/>
<module name="intellij.platform.testFramework.core"/>
<module name="intellij.platform.testFramework.common"/>
</dependencies>
<extensions defaultExtensionNs="com.intellij">
<applicationService serviceInterface="com.intellij.openapi.project.ProjectManager"
serviceImplementation="com.intellij.project.TestProjectManager"
testServiceImplementation="com.intellij.project.TestProjectManager"
headlessImplementation="com.intellij.project.TestProjectManager"
overrides="true"/>
<applicationService serviceInterface="com.intellij.ide.DataManager"
serviceImplementation="com.intellij.ide.impl.HeadlessDataManager"
testServiceImplementation="com.intellij.ide.impl.HeadlessDataManager"
headlessImplementation="com.intellij.ide.impl.HeadlessDataManager"
overrides="true"/>
</extensions>
</idea-plugin>
@@ -0,0 +1,39 @@
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.lambda.sampleTestsWithFixtures
import com.intellij.lambda.sampleTestsWithFixtures.util.openNewEditor
import com.intellij.lambda.testFramework.junit.ExecuteInMonolithAndSplitMode
import com.intellij.lambda.testFramework.junit.IdeRunMode
import com.intellij.lambda.testFramework.testApi.editor.openFile
import com.intellij.lambda.testFramework.testApi.getProject
import com.intellij.lambda.testFramework.testApi.getProjects
import com.intellij.lambda.testFramework.testApi.waitForProject
import com.intellij.lambda.testFramework.utils.BackgroundRunWithLambda
import com.intellij.openapi.diagnostic.Logger
import kotlinx.coroutines.runBlocking
import org.junit.jupiter.api.TestTemplate
import kotlin.time.Duration.Companion.seconds
@ExecuteInMonolithAndSplitMode
class SampleTest {
@TestTemplate
fun `serialized test`(ide: BackgroundRunWithLambda) = runBlocking {
ide.apply {
runInBackend {
//waitForProject(20.seconds)
}
run {
openNewEditor("/src/com/example/Foo.java")
Logger.getInstance("test").warn("Projects: " + getProjects().joinToString { it.name })
}
runInBackend {
Logger.getInstance("test").warn("backend Projects: " + getProject())
openFile("src/com/example/Foo.java", waitForReadyState = false, requireFocus = false)
}
}
Unit
}
}
@@ -0,0 +1,19 @@
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.lambda.sampleTestsWithFixtures.util
import com.intellij.lambda.testFramework.utils.LambdaTestPluginHolder
import org.junit.jupiter.api.extension.AfterAllCallback
import org.junit.jupiter.api.extension.BeforeAllCallback
import org.junit.jupiter.api.extension.ExtensionContext
class SetLambdaPluginCallback : BeforeAllCallback, AfterAllCallback {
override fun beforeAll(context: ExtensionContext) {
LambdaTestPluginHolder.setupAdditionalLambdaPlugin("intellij.lambda.sampleTestsWithFixtures._test",
"intellij.lambda.sampleTestsWithFixtures.plugin",
"lambda-sampleTestsWithFixtures-plugin")
}
override fun afterAll(context: ExtensionContext) {
LambdaTestPluginHolder.cleanUpAdditionalLambdaPlugin()
}
}
@@ -0,0 +1,40 @@
// Copyright 2000-2025 JetBrains s.r.o. and contributors. Use of this source code is governed by the Apache 2.0 license.
package com.intellij.lambda.sampleTestsWithFixtures.util
import com.intellij.remoteDev.tests.LambdaIdeContext
import com.intellij.testFramework.fixtures.IdeaTestFixtureFactory
import com.intellij.testFramework.fixtures.impl.CodeInsightTestFixtureImpl
import com.intellij.testFramework.fixtures.impl.TempDirTestFixtureImpl
import kotlinx.coroutines.currentCoroutineContext
import kotlinx.coroutines.job
context(lambdaIdeContext: LambdaIdeContext)
suspend fun openNewEditor(relativePath: String) {
val projectBuilder = IdeaTestFixtureFactory.getFixtureFactory().createFixtureBuilder("Test")
val codeInsightFixture = CodeInsightTestFixtureImpl(projectBuilder.fixture, TempDirTestFixtureImpl())
codeInsightFixture.setUp()
codeInsightFixture.openFileInEditor(
codeInsightFixture
.addFileToProject(
relativePath,
// language=java
"""
package com.example;
class Foo {
private boolean unboxedZ = false;
private byte unboxedB = 0;
private char unboxedC = 'a';
private double unboxedD = 0.0;
private float unboxedF = 0.0f;
private int unboxedI = 0;
private long unboxedJ = 0l;
private short unboxedS = 0;
}
"""
.trimIndent(),
)
.virtualFile
)
currentCoroutineContext().job.invokeOnCompletion { codeInsightFixture.tearDown() }
}