Skip to content

Commit

Permalink
Refactor test utilities in plugin and update ideStarter version
Browse files Browse the repository at this point in the history
This commit includes the refactoring of various test utilities in the package search plugin test modules to use new classes TestContainerImpl and TestFailedLineManager. Replaced the method CurrentTestMethod.hyphenateWithClass() with a new function call. Also updated the ideStarter version from LATEST-EAP-SNAPSHOT to 233-SNAPSHOT in packagesearch.versions.toml.
  • Loading branch information
fscarponi committed May 8, 2024
1 parent 36b4ae5 commit 3ab1298
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 10 deletions.
File renamed without changes.
2 changes: 1 addition & 1 deletion packagesearch.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ logback = "1.4.11"
nitrite = "3.4.4"
packagesearchApiModels = "3.0.0"
jewel = "0.15.0"
ideStarter = "LATEST-EAP-SNAPSHOT"
ideStarter = "233-SNAPSHOT"

[libraries]
assertk = { module = "com.willowtreeapps.assertk:assertk-jvm", version.ref = "assertk" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,11 @@ package com.jetbrains.packagesearch.plugin.tests

import com.intellij.ide.starter.ide.IDETestContext
import com.intellij.ide.starter.ide.IdeProductProvider
import com.intellij.ide.starter.junit5.hyphenateWithClass
import com.intellij.ide.starter.project.LocalProjectInfo
import com.intellij.ide.starter.project.TestCaseTemplate
import com.intellij.ide.starter.runner.CurrentTestMethod
import com.intellij.ide.starter.runner.Starter
import com.intellij.ide.starter.runner.TestContainerImpl
import com.intellij.openapi.util.io.toNioPathOrNull
import com.intellij.testIntegration.TestFailedLineManager
import com.intellij.tools.ide.performanceTesting.commands.CommandChain
import com.intellij.tools.ide.performanceTesting.commands.SdkObject
import com.jetbrains.packagesearch.plugin.tests.dumps.DumpPackageSearchModules
Expand All @@ -18,6 +17,7 @@ import kotlin.io.path.Path
import kotlin.io.path.copyTo
import kotlin.io.path.createDirectories
import kotlin.io.path.isRegularFile
import kotlin.io.path.nameWithoutExtension
import kotlin.io.path.outputStream
import kotlin.io.path.readLines
import kotlin.io.path.toPath
Expand Down Expand Up @@ -154,17 +154,14 @@ private fun fetchJavaLocation(javaHome: Path): JavaLocation {
* @param projectPath The path to the project.
* @return The IDETestContext object.
*/
internal fun buildIdeContext(projectPath: Path): IDETestContext {
internal fun buildIdeContext(projectPath: Path, context: TestContainerImpl): IDETestContext {
val testCase = object : TestCaseTemplate(IdeProductProvider.IC) {
val project = withProject(LocalProjectInfo(projectPath))
}

val sdk = fetchJavaLocation().toSdkObject()

return Starter.newContext(
CurrentTestMethod.hyphenateWithClass(),
testCase.project.useRelease("233.3.5"),
)
return context.initializeTestContext(testName = projectPath.nameWithoutExtension, testCase.project)
.setSharedIndexesDownload(true)
.addProjectToTrustedLocations()
.disableFusSendingOnIdeClose()
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
package com.jetbrains.packagesearch.plugin.tests.projectservice

import com.intellij.ide.starter.junit5.JUnit5StarterAssistant
import com.intellij.ide.starter.runner.TestContainerImpl
import com.intellij.testIntegration.TestFailedLineManager
import com.intellij.tools.ide.performanceTesting.commands.CommandChain
import com.intellij.tools.ide.performanceTesting.commands.exitApp
import com.intellij.tools.ide.performanceTesting.commands.waitForSmartMode
Expand Down Expand Up @@ -29,6 +31,9 @@ import org.junit.jupiter.params.provider.MethodSource
@ExtendWith(JUnit5StarterAssistant::class)
abstract class PackageSearchProjectServiceTest {

private lateinit var testInfo: TestFailedLineManager.TestInfo
private lateinit var context: TestContainerImpl

abstract val resourcePath: String

private fun getProjects() =
Expand Down Expand Up @@ -68,7 +73,7 @@ abstract class PackageSearchProjectServiceTest {
editProject(projectDir)

//IDE context setup
val testContext = buildIdeContext(projectDir)
val testContext = buildIdeContext(projectDir, context)

val dumpPkgsDataChain = CommandChain()
.waitForSmartMode()
Expand Down

0 comments on commit 3ab1298

Please sign in to comment.