Skip to content

Commit

Permalink
Number of generated tests is not properly counted in some cases #983 (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
Vassiliy-Kudryashov authored Oct 19, 2022
1 parent 40cedc6 commit 5a242a0
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package org.utbot.framework.codegen.model.constructor.tree
import org.utbot.common.appendHtmlLine
import org.utbot.framework.codegen.model.constructor.CgMethodTestSet
import org.utbot.framework.codegen.model.tree.CgTestMethod
import org.utbot.framework.codegen.model.tree.CgTestMethodType
import org.utbot.framework.codegen.model.tree.CgTestMethodType.*
import org.utbot.framework.plugin.api.ExecutableId
import org.utbot.framework.plugin.api.util.kClass
Expand Down Expand Up @@ -35,15 +34,15 @@ data class TestsGenerationReport(
val errors = executables.map { it.countErrors() }
val overallErrors = errors.sum()

appendHtmlLine("Successful test methods: ${testMethodsStatistic.sumBy { it.successful }}")
appendHtmlLine("Successful test methods: ${testMethodsStatistic.sumOf { it.successful }}")
appendHtmlLine(
"Failing because of unexpected exception test methods: ${testMethodsStatistic.sumBy { it.failing }}"
"Failing because of unexpected exception test methods: ${testMethodsStatistic.sumOf { it.failing }}"
)
appendHtmlLine(
"Failing because of exceeding timeout test methods: ${testMethodsStatistic.sumBy { it.timeout }}"
"Failing because of exceeding timeout test methods: ${testMethodsStatistic.sumOf { it.timeout }}"
)
appendHtmlLine(
"Failing because of possible JVM crash test methods: ${testMethodsStatistic.sumBy { it.crashes }}"
"Failing because of possible JVM crash test methods: ${testMethodsStatistic.sumOf { it.crashes }}"
)
appendHtmlLine("Not generated because of internal errors test methods: $overallErrors")
}
Expand Down Expand Up @@ -71,17 +70,16 @@ data class TestsGenerationReport(
}
}

fun countTestMethods() = executables.map { it.countTestMethods() }.sumOf { it.count }

fun toString(isShort: Boolean): String = buildString {
appendHtmlLine("Target: ${classUnderTest.qualifiedName}")
if (initialWarnings.isNotEmpty()) {
initialWarnings.forEach { appendHtmlLine(it()) }
appendHtmlLine()
}

val testMethodsStatistic = executables.map { it.countTestMethods() }
val overallTestMethods = testMethodsStatistic.sumBy { it.count }

appendHtmlLine("Overall test methods: $overallTestMethods")
appendHtmlLine("Overall test methods: ${countTestMethods()}")

if (!isShort) {
appendHtmlLine(detailedStatistics)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ private fun EngineProcessModel.setup(
processInitialWarnings(accumulatedReport, params)

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

if (accumulatedReport.initialWarnings.isNotEmpty()) {
accumulatedReport.initialWarnings.forEach { appendHtmlLine(it()) }
Expand Down

0 comments on commit 5a242a0

Please sign in to comment.