diff --git a/utbot-summary/src/main/kotlin/org/utbot/summary/Summarization.kt b/utbot-summary/src/main/kotlin/org/utbot/summary/Summarization.kt index dfc0547821..fb473101e5 100644 --- a/utbot-summary/src/main/kotlin/org/utbot/summary/Summarization.kt +++ b/utbot-summary/src/main/kotlin/org/utbot/summary/Summarization.kt @@ -68,12 +68,32 @@ class Summarization(val sourceFile: File?, val invokeDescriptions: List() val clustersToReturn = mutableListOf() + // TODO: Now it excludes tests generated by Fuzzer, handle it properly, related to the https://github.com/UnitTestBot/UTBotJava/issues/428 + val executionsProducedByFuzzer = getExecutionsWithEmptyPath(testCase) + + if (executionsProducedByFuzzer.isNotEmpty()) { + executionsProducedByFuzzer.forEach { + logger.info { + "The path for test ${it.testMethodName} " + + "for method ${testCase.method.clazz.qualifiedName} is empty and summaries could not be generated." + } + } + + clustersToReturn.add( + UtExecutionCluster( + UtClusterInfo(), + executionsProducedByFuzzer + ) + ) + } + // analyze if (jimpleBody != null && sootToAST != null) { val methodUnderTest = jimpleBody.method @@ -83,9 +103,9 @@ class Summarization(val sourceFile: File?, val invokeDescriptions: List 1 //there is more than one successful execution - && clusterTraceTags.traceTags.size > 1 //add if there is more than 1 execution + GENERATE_CLUSTER_COMMENTS && clusterTraceTags.isSuccessful // add only for successful executions + && numberOfSuccessfulClusters > 1 // there is more than one successful execution + && clusterTraceTags.traceTags.size > 1 // add if there is more than 1 execution ) { SimpleClusterCommentBuilder(clusterTraceTags.commonStepsTraceTag, sootToAST) .buildString(methodUnderTest) @@ -113,20 +133,14 @@ class Summarization(val sourceFile: File?, val invokeDescriptions: List() - //we only want to find intersections if there is more than one successful execution + // we only want to find intersections if there is more than one successful execution if (numberOfSuccessfulClusters > 1 && REMOVE_INTERSECTIONS) { val commonStepsInSuccessfulEx = listOfSplitSteps .filterIndexed { i, _ -> clusteredExecutions[i] is SuccessfulExecutionCluster } //search only in successful @@ -46,7 +46,7 @@ class TagGenerator { } } - //for every cluster and step add TraceTagCluster + // for every cluster and step add TraceTagCluster clusteredExecutions.zip(listOfSplitSteps) { cluster, splitSteps -> val commonStepsInCluster = if (stepsIntersections.isNotEmpty() && numberOfSuccessfulClusters > 1) { @@ -70,11 +70,10 @@ class TagGenerator { ) ) } - }//clusteredExecutions should not be empty! + } // clusteredExecutions should not be empty! return traceTagClusters } - } /** @@ -95,7 +94,7 @@ private fun generateExecutionTags(executions: List, splitSteps: Spl * @return clustered executions */ private fun toClusterExecutions(testCase: UtTestCase): List { - val methodExecutions = testCase.executions + val methodExecutions = testCase.executions.filter { it.path.isNotEmpty() } // TODO: Now it excludes tests generated by Fuzzer, handle it properly, related to the https://github.com/UnitTestBot/UTBotJava/issues/428 val clusters = mutableListOf() val commentPostfix = "for method ${testCase.method.displayName}"