Skip to content

Commit b55fef0

Browse files
Improve documentation for regions in parametrized tests #1301 (#1340)
* Improve documentation for regions in parametrized tests
1 parent 1320f17 commit b55fef0

File tree

1 file changed

+31
-14
lines changed

1 file changed

+31
-14
lines changed

utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/constructor/tree/CgTestClassConstructor.kt

Lines changed: 31 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,11 @@ open class CgTestClassConstructor(val context: CgContext) :
105105

106106
val currentTestClassDataProviderMethods = currentTestClassContext.cgDataProviderMethods
107107
if (currentTestClassDataProviderMethods.isNotEmpty()) {
108-
staticDeclarationRegions += CgStaticsRegion("Data providers", currentTestClassDataProviderMethods)
108+
staticDeclarationRegions +=
109+
CgStaticsRegion(
110+
"Data provider methods for parametrized tests",
111+
currentTestClassDataProviderMethods,
112+
)
109113
}
110114

111115
if (currentTestClass == outerMostTestClass) {
@@ -223,34 +227,47 @@ open class CgTestClassConstructor(val context: CgContext) :
223227
}
224228

225229
regions += CgSimpleRegion(
226-
"Tests for method ${methodUnderTest.humanReadableName} that cannot be presented as parameterized",
227-
collectAdditionalTestsForParameterizedMode(testSet),
230+
"SYMBOLIC EXECUTION: additional tests for symbolic executions for method ${methodUnderTest.humanReadableName}",
231+
collectAdditionalSymbolicTestsForParametrizedMode(testSet),
232+
)
233+
234+
regions += CgSimpleRegion(
235+
"FUZZER: Tests for method ${methodUnderTest.humanReadableName}",
236+
collectFuzzerTestsForParameterizedMode(testSet),
228237
)
229238
}
230239

231-
private fun collectAdditionalTestsForParameterizedMode(testSet: CgMethodTestSet): List<CgTestMethod> {
232-
val (methodUnderTest, _, _, _) = testSet
233-
val testCaseTestMethods = mutableListOf<CgTestMethod>()
240+
/**
241+
* Collects standard tests for fuzzer executions in parametrized mode.
242+
* This is a requirement from [https://github.com/UnitTestBot/UTBotJava/issues/1137].
243+
*/
244+
private fun collectFuzzerTestsForParameterizedMode(testSet: CgMethodTestSet): List<CgTestMethod> {
245+
val testMethods = mutableListOf<CgTestMethod>()
234246

235-
// We cannot track mocking in fuzzed executions,
236-
// so we generate standard tests for each [UtFuzzedExecution].
237-
// [https://github.com/UnitTestBot/UTBotJava/issues/1137]
238247
testSet.executions
239248
.filterIsInstance<UtFuzzedExecution>()
240249
.forEach { execution ->
241-
testCaseTestMethods += methodConstructor.createTestMethod(methodUnderTest, execution)
250+
testMethods += methodConstructor.createTestMethod(testSet.executableId, execution)
242251
}
243252

244-
// Also, we generate standard tests for symbolic executions with force mocking.
245-
// [https://github.com/UnitTestBot/UTBotJava/issues/1231]
253+
return testMethods
254+
}
255+
256+
/**
257+
* Collects standard tests for symbolic executions that can't be included into parametrized tests.
258+
* This is a requirement from [https://github.com/UnitTestBot/UTBotJava/issues/1231].
259+
*/
260+
private fun collectAdditionalSymbolicTestsForParametrizedMode(testSet: CgMethodTestSet): List<CgTestMethod> {
261+
val testMethods = mutableListOf<CgTestMethod>()
262+
246263
testSet.executions
247264
.filterIsInstance<UtSymbolicExecution>()
248265
.filter { it.containsMocking }
249266
.forEach { execution ->
250-
testCaseTestMethods += methodConstructor.createTestMethod(methodUnderTest, execution)
267+
testMethods += methodConstructor.createTestMethod(testSet.executableId, execution)
251268
}
252269

253-
return testCaseTestMethods
270+
return testMethods
254271
}
255272

256273
/**

0 commit comments

Comments
 (0)