@@ -5,6 +5,7 @@ import org.utbot.framework.UtSettings
55import org.utbot.framework.plugin.api.UtClusterInfo
66import org.utbot.framework.plugin.api.UtExecution
77import org.utbot.framework.plugin.api.UtExecutionCluster
8+ import org.utbot.framework.plugin.api.UtExecutionCreator
89import org.utbot.framework.plugin.api.UtMethodTestSet
910import org.utbot.instrumentation.instrumentation.instrumenter.Instrumenter
1011import org.utbot.summary.SummarySentenceConstants.NEW_LINE
@@ -75,29 +76,50 @@ class Summarization(val sourceFile: File?, val invokeDescriptions: List<InvokeDe
7576 val updatedExecutions = mutableListOf<UtExecution >()
7677 val clustersToReturn = mutableListOf<UtExecutionCluster >()
7778
78- // TODO: Now it excludes tests generated by Fuzzer, handle it properly, related to the https://github.com/UnitTestBot/UTBotJava/issues/428
79- val executionsProducedByFuzzer = getExecutionsWithEmptyPath( testSet)
79+ // handles tests produced by fuzzing
80+ val executionsProducedByFuzzer = testSet.executions.filter { it.createdBy == UtExecutionCreator . FUZZER }
8081
8182 if (executionsProducedByFuzzer.isNotEmpty()) {
8283 executionsProducedByFuzzer.forEach {
8384 logger.info {
84- " The path for test ${it.testMethodName} " +
85+ " Test is created by Fuzzing. The path for test ${it.testMethodName} " +
8586 " for method ${testSet.method.clazz.qualifiedName} is empty and summaries could not be generated."
8687 }
8788 }
8889
8990 clustersToReturn.add(
9091 UtExecutionCluster (
91- UtClusterInfo (),
92+ UtClusterInfo (), // TODO: add something https://github.com/UnitTestBot/UTBotJava/issues/430
9293 executionsProducedByFuzzer
9394 )
9495 )
9596 }
9697
98+ // handles tests produced by symbolic engine, but with empty paths
99+ val executionsWithEmptyPaths = getExecutionsCreatedBySymbolicEngineWithEmptyPath(testSet)
100+
101+ if (executionsWithEmptyPaths.isNotEmpty()) {
102+ executionsWithEmptyPaths.forEach {
103+ logger.info {
104+ " Test is created by Symbolic Engine. The path for test ${it.testMethodName} " +
105+ " for method ${testSet.method.clazz.qualifiedName} is empty and summaries could not be generated."
106+ }
107+ }
108+
109+ clustersToReturn.add(
110+ UtExecutionCluster (
111+ UtClusterInfo (), // TODO: https://github.com/UnitTestBot/UTBotJava/issues/430
112+ executionsWithEmptyPaths
113+ )
114+ )
115+ }
116+
117+ val testSetForAnalysis = prepareTestSetForByteCodeAnalysis(testSet)
118+
97119 // analyze
98120 if (jimpleBody != null && sootToAST != null ) {
99121 val methodUnderTest = jimpleBody.method
100- val clusteredTags = tagGenerator.testSetToTags(testSet )
122+ val clusteredTags = tagGenerator.testSetToTags(testSetForAnalysis )
101123 jimpleBodyAnalysis.traceStructuralAnalysis(jimpleBody, clusteredTags, methodUnderTest, invokeDescriptions)
102124 val numberOfSuccessfulClusters = clusteredTags.filter { it.isSuccessful }.size
103125 for (clusterTraceTags in clusteredTags) {
@@ -108,21 +130,22 @@ class Summarization(val sourceFile: File?, val invokeDescriptions: List<InvokeDe
108130 && clusterTraceTags.traceTags.size > 1 // add if there is more than 1 execution
109131 ) {
110132 SimpleClusterCommentBuilder (clusterTraceTags.commonStepsTraceTag, sootToAST)
111- .buildString(methodUnderTest)
112- .takeIf { it.isNotBlank() }
113- ?.let {
114- buildString {
115- append(" ${NEW_LINE } Common steps:" )
116- append(" $NEW_LINE$it " )
117- }
133+ .buildString(methodUnderTest)
134+ .takeIf { it.isNotBlank() }
135+ ?.let {
136+ buildString {
137+ append(" ${NEW_LINE } Common steps:" )
138+ append(" $NEW_LINE$it " )
118139 }
140+ }
119141 } else {
120142 null
121143 }
122144
123145 for (traceTags in clusterTraceTags.traceTags) {
124146 if (GENERATE_COMMENTS ) {
125- traceTags.execution.summary = SimpleCommentBuilder (traceTags, sootToAST).buildDocStmts(methodUnderTest)
147+ traceTags.execution.summary =
148+ SimpleCommentBuilder (traceTags, sootToAST).buildDocStmts(methodUnderTest)
126149 }
127150
128151 if (GENERATE_DISPLAY_NAMES || GENERATE_NAMES ) {
@@ -164,8 +187,21 @@ class Summarization(val sourceFile: File?, val invokeDescriptions: List<InvokeDe
164187 return listOf (UtExecutionCluster (UtClusterInfo (), testSet.executions))
165188 }
166189
167- private fun getExecutionsWithEmptyPath (testSet : UtMethodTestSet ) =
168- testSet.executions.filter { it.path.isEmpty() }
190+ private fun prepareTestSetForByteCodeAnalysis (testSet : UtMethodTestSet ): UtMethodTestSet {
191+ val executions =
192+ testSet.executions.filterNot { it.createdBy == UtExecutionCreator .FUZZER || (it.createdBy == UtExecutionCreator .SYMBOLIC_ENGINE && it.path.isEmpty()) }
193+
194+ return UtMethodTestSet (
195+ method = testSet.method,
196+ executions = executions,
197+ jimpleBody = testSet.jimpleBody,
198+ errors = testSet.errors,
199+ clustersInfo = testSet.clustersInfo
200+ )
201+ }
202+
203+ private fun getExecutionsCreatedBySymbolicEngineWithEmptyPath (testSet : UtMethodTestSet ) =
204+ testSet.executions.filter { it.createdBy == UtExecutionCreator .SYMBOLIC_ENGINE && it.path.isEmpty() }
169205
170206 /*
171207 * asts of invokes also included
0 commit comments