Skip to content

Number of generated tests is not properly counted in some cases #983 #1178

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Show file tree
Hide file tree
Changes from all commits
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
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