Skip to content

Commit ad4965c

Browse files
committed
Handle empty test cases list - improved (#1098)
1 parent 0a52a4e commit ad4965c

File tree

2 files changed

+5
-6
lines changed

2 files changed

+5
-6
lines changed

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

+3-4
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,16 @@ data class TestsGenerationReport(
1919
var crashExecutions: MethodGeneratedTests = mutableMapOf(),
2020
var errors: MutableMap<ExecutableId, ErrorsCount> = mutableMapOf()
2121
) {
22-
val classUnderTest: KClass<*>
22+
val classUnderTest: KClass<*>?
2323
get() = executables.firstOrNull()?.classId?.kClass
24-
?: error("No executables found in test report")
2524

2625
val initialWarnings: MutableList<() -> String> = mutableListOf()
2726
val hasWarnings: Boolean
2827
get() = initialWarnings.isNotEmpty()
2928

3029
val detailedStatistics: String
3130
get() = buildString {
32-
appendHtmlLine("Class: ${classUnderTest.qualifiedName}")
31+
classUnderTest?.let { appendHtmlLine("Class: ${it.qualifiedName}") }
3332
val testMethodsStatistic = executables.map { it.countTestMethods() }
3433
val errors = executables.map { it.countErrors() }
3534
val overallErrors = errors.sum()
@@ -71,7 +70,7 @@ data class TestsGenerationReport(
7170
}
7271

7372
fun toString(isShort: Boolean): String = buildString {
74-
appendHtmlLine("Target: ${classUnderTest.qualifiedName}")
73+
classUnderTest?.let { appendHtmlLine("Target: ${it.qualifiedName}") }
7574
if (initialWarnings.isNotEmpty()) {
7675
initialWarnings.forEach { appendHtmlLine(it()) }
7776
appendHtmlLine()

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

+2-2
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ private fun EngineProcessModel.setup(
197197
appendHtmlLine(report.toString(isShort = true))
198198

199199
val classUnderTestPackageName =
200-
report.classUnderTest.java.nameOfPackage
200+
report.classUnderTest?.java?.nameOfPackage ?: ""
201201

202202
destinationWarningMessage(testPackageName, classUnderTestPackageName)
203203
?.let {
@@ -227,7 +227,7 @@ private fun EngineProcessModel.setup(
227227

228228
for (report in reports) {
229229
val classUnderTestPackageName =
230-
report.classUnderTest.java.nameOfPackage
230+
report.classUnderTest?.java?.nameOfPackage ?: ""
231231

232232
hasWarnings = hasWarnings || report.hasWarnings
233233
if (!isMultiPackage) {

0 commit comments

Comments
 (0)