Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Apply review fixes
  • Loading branch information
EgorkaKulikov committed Jul 19, 2022
commit f4dd9ab8a4badace17afd5548a2e64bf042f1c5e
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import org.junit.jupiter.api.extension.ExtensionContext
import org.junit.jupiter.api.fail
import org.junit.jupiter.engine.descriptor.ClassTestDescriptor
import org.junit.jupiter.engine.descriptor.JupiterEngineDescriptor
import java.nio.file.Path

@TestInstance(TestInstance.Lifecycle.PER_CLASS)
@TestMethodOrder(MethodOrderer.OrderAnnotation::class)
Expand Down Expand Up @@ -173,6 +174,10 @@ abstract class CodeGenerationIntegrationTest(

private val logger = KotlinLogging.logger { }

@JvmStatic
protected val testCaseGeneratorCache = mutableMapOf<BuildInfo, TestSpecificTestCaseGenerator>()
data class BuildInfo(val buildDir: Path, val dependencyPath: String?)

private fun getTestPackageSize(packageName: String): Int =
// filter all not disabled tests classes
allRunningTestClasses
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,9 @@ internal abstract class UtModelTestCaseChecker(
previousClassLocation = classLocation
}

val buildInfo = CodeGenerationIntegrationTest.Companion.BuildInfo(buildDir, dependencyPath = null)
val testCaseGenerator = testCaseGeneratorCache
.getOrPut(buildDir) {
.getOrPut(buildInfo) {
TestSpecificTestCaseGenerator(
buildDir,
classpath = null,
Expand All @@ -150,8 +151,6 @@ internal abstract class UtModelTestCaseChecker(
return testCaseGenerator.generate(method, mockStrategy)
}

private val testCaseGeneratorCache = mutableMapOf<Path, TestSpecificTestCaseGenerator>()

protected inline fun <reified T> UtExecutionResult.isException(): Boolean = exceptionOrNull() is T

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2490,7 +2490,7 @@ abstract class UtValueTestCaseChecker(
mockStrategy: MockStrategyApi,
additionalDependenciesClassPath: String
): UtMethodTestSet {
val buildInfo = BuildInfo(buildDir, additionalDependenciesClassPath)
val buildInfo = CodeGenerationIntegrationTest.Companion.BuildInfo(buildDir, additionalDependenciesClassPath)

val testCaseGenerator = testCaseGeneratorCache
.getOrPut(buildInfo) {
Expand All @@ -2511,7 +2511,7 @@ abstract class UtValueTestCaseChecker(
val additionalDependenciesClassPath =
computeAdditionalDependenciesClasspathAndBuildDir(method, additionalDependencies)
withUtContext(UtContext(method.clazz.java.classLoader)) {
val buildInfo = BuildInfo(buildDir, additionalDependenciesClassPath)
val buildInfo = CodeGenerationIntegrationTest.Companion.BuildInfo(buildDir, additionalDependenciesClassPath)
val testCaseGenerator = testCaseGeneratorCache
.getOrPut(buildInfo) {
TestSpecificTestCaseGenerator(
Expand Down Expand Up @@ -2551,9 +2551,6 @@ abstract class UtValueTestCaseChecker(
)

data class MethodResult(val testCase: UtMethodTestSet, val coverage: Coverage)

data class BuildInfo(val buildDir: Path, val dependencyPath: String)
private val testCaseGeneratorCache = mutableMapOf<BuildInfo, TestSpecificTestCaseGenerator>()
}

@Suppress("UNCHECKED_CAST")
Expand Down