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
Construct shallow result models during non-rerun runs
  • Loading branch information
IlyaMuravjov committed Sep 11, 2023
commit 472a97141367887c5b94d5919cba5c59cd26ca60
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ class UtModelConstructor(
private val constructedObjects = IdentityHashMap<Any, UtModel>()

companion object {
private const val DEFAULT_MAX_DEPTH = 7L
const val DEFAULT_MAX_DEPTH = 7L

fun createOnlyUserClassesConstructor(
pathsToUserClasses: Set<String>,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,21 +40,28 @@ class ModelConstructionPhase(
}
}

private val constructorConfiguration = ConstructorConfiguration()
private lateinit var constructor: UtModelConstructor

class ConstructorConfiguration {
lateinit var cache: IdentityHashMap<Any, UtModel>
lateinit var strategy: UtCompositeModelStrategy
var maxDepth: Long = UtModelConstructor.DEFAULT_MAX_DEPTH
}

fun preconfigureConstructor(block: ConstructorConfiguration.() -> Unit) {
constructorConfiguration.block()
}

fun configureConstructor(block: ConstructorConfiguration.() -> Unit) {
ConstructorConfiguration().run {
constructorConfiguration.run {
block()
constructor = UtModelConstructor(
objectToModelCache = cache,
utModelWithCompositeOriginConstructorFinder = utModelWithCompositeOriginConstructorFinder,
compositeModelStrategy = strategy,
idGenerator = idGenerator,
maxDepth = maxDepth,
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ class SpringUtExecutionInstrumentation(

return try {
delegateInstrumentation.invoke(clazz, methodSignature, arguments, parameters) { invokeBasePhases ->
if (!parameters.isRerun)
modelConstructionPhase.preconfigureConstructor { maxDepth = 0 }

phasesWrapper {
// NB! beforeTestMethod() and afterTestMethod() are intentionally called inside phases,
// so they are executed in one thread with method under test
Expand Down