Skip to content

Commit 5a242a0

Browse files
Number of generated tests is not properly counted in some cases #983 (#1178)
1 parent 40cedc6 commit 5a242a0

File tree

2 files changed

+8
-10
lines changed

2 files changed

+8
-10
lines changed

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

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package org.utbot.framework.codegen.model.constructor.tree
33
import org.utbot.common.appendHtmlLine
44
import org.utbot.framework.codegen.model.constructor.CgMethodTestSet
55
import org.utbot.framework.codegen.model.tree.CgTestMethod
6-
import org.utbot.framework.codegen.model.tree.CgTestMethodType
76
import org.utbot.framework.codegen.model.tree.CgTestMethodType.*
87
import org.utbot.framework.plugin.api.ExecutableId
98
import org.utbot.framework.plugin.api.util.kClass
@@ -35,15 +34,15 @@ data class TestsGenerationReport(
3534
val errors = executables.map { it.countErrors() }
3635
val overallErrors = errors.sum()
3736

38-
appendHtmlLine("Successful test methods: ${testMethodsStatistic.sumBy { it.successful }}")
37+
appendHtmlLine("Successful test methods: ${testMethodsStatistic.sumOf { it.successful }}")
3938
appendHtmlLine(
40-
"Failing because of unexpected exception test methods: ${testMethodsStatistic.sumBy { it.failing }}"
39+
"Failing because of unexpected exception test methods: ${testMethodsStatistic.sumOf { it.failing }}"
4140
)
4241
appendHtmlLine(
43-
"Failing because of exceeding timeout test methods: ${testMethodsStatistic.sumBy { it.timeout }}"
42+
"Failing because of exceeding timeout test methods: ${testMethodsStatistic.sumOf { it.timeout }}"
4443
)
4544
appendHtmlLine(
46-
"Failing because of possible JVM crash test methods: ${testMethodsStatistic.sumBy { it.crashes }}"
45+
"Failing because of possible JVM crash test methods: ${testMethodsStatistic.sumOf { it.crashes }}"
4746
)
4847
appendHtmlLine("Not generated because of internal errors test methods: $overallErrors")
4948
}
@@ -71,17 +70,16 @@ data class TestsGenerationReport(
7170
}
7271
}
7372

73+
fun countTestMethods() = executables.map { it.countTestMethods() }.sumOf { it.count }
74+
7475
fun toString(isShort: Boolean): String = buildString {
7576
appendHtmlLine("Target: ${classUnderTest.qualifiedName}")
7677
if (initialWarnings.isNotEmpty()) {
7778
initialWarnings.forEach { appendHtmlLine(it()) }
7879
appendHtmlLine()
7980
}
8081

81-
val testMethodsStatistic = executables.map { it.countTestMethods() }
82-
val overallTestMethods = testMethodsStatistic.sumBy { it.count }
83-
84-
appendHtmlLine("Overall test methods: $overallTestMethods")
82+
appendHtmlLine("Overall test methods: ${countTestMethods()}")
8583

8684
if (!isShort) {
8785
appendHtmlLine(detailedStatistics)

utbot-framework/src/main/kotlin/org/utbot/framework/process/EngineMain.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -218,7 +218,7 @@ private fun EngineProcessModel.setup(
218218
processInitialWarnings(accumulatedReport, params)
219219

220220
val message = buildString {
221-
appendHtmlLine("${reports.sumBy { it.executables.size }} tests generated for ${reports.size} classes.")
221+
appendHtmlLine("${reports.sumOf { it.countTestMethods() }} tests generated for ${reports.size} classes.")
222222

223223
if (accumulatedReport.initialWarnings.isNotEmpty()) {
224224
accumulatedReport.initialWarnings.forEach { appendHtmlLine(it()) }

0 commit comments

Comments
 (0)