@@ -68,12 +68,32 @@ class Summarization(val sourceFile: File?, val invokeDescriptions: List<InvokeDe
68
68
}
69
69
return listOf (UtExecutionCluster (UtClusterInfo (), testCase.executions))
70
70
}
71
+
71
72
// init
72
73
val sootToAST = sootToAST(testCase)
73
74
val jimpleBody = testCase.jimpleBody
74
75
val updatedExecutions = mutableListOf<UtExecution >()
75
76
val clustersToReturn = mutableListOf<UtExecutionCluster >()
76
77
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(testCase)
80
+
81
+ if (executionsProducedByFuzzer.isNotEmpty()) {
82
+ executionsProducedByFuzzer.forEach {
83
+ logger.info {
84
+ " The path for test ${it.testMethodName} " +
85
+ " for method ${testCase.method.clazz.qualifiedName} is empty and summaries could not be generated."
86
+ }
87
+ }
88
+
89
+ clustersToReturn.add(
90
+ UtExecutionCluster (
91
+ UtClusterInfo (),
92
+ executionsProducedByFuzzer
93
+ )
94
+ )
95
+ }
96
+
77
97
// analyze
78
98
if (jimpleBody != null && sootToAST != null ) {
79
99
val methodUnderTest = jimpleBody.method
@@ -83,9 +103,9 @@ class Summarization(val sourceFile: File?, val invokeDescriptions: List<InvokeDe
83
103
for (clusterTraceTags in clusteredTags) {
84
104
val clusterHeader = clusterTraceTags.summary.takeIf { GENERATE_CLUSTER_COMMENTS }
85
105
val clusterContent = if (
86
- GENERATE_CLUSTER_COMMENTS && clusterTraceTags.isSuccessful // add only for successful executions
87
- && numberOfSuccessfulClusters > 1 // there is more than one successful execution
88
- && clusterTraceTags.traceTags.size > 1 // add if there is more than 1 execution
106
+ GENERATE_CLUSTER_COMMENTS && clusterTraceTags.isSuccessful // add only for successful executions
107
+ && numberOfSuccessfulClusters > 1 // there is more than one successful execution
108
+ && clusterTraceTags.traceTags.size > 1 // add if there is more than 1 execution
89
109
) {
90
110
SimpleClusterCommentBuilder (clusterTraceTags.commonStepsTraceTag, sootToAST)
91
111
.buildString(methodUnderTest)
@@ -113,20 +133,14 @@ class Summarization(val sourceFile: File?, val invokeDescriptions: List<InvokeDe
113
133
val nameIndex = namesCounter.getOrPut(name) { 0 }
114
134
namesCounter[name] = nameIndex + 1
115
135
updatedExecutions + = traceTags.execution
116
- if (GENERATE_DISPLAY_NAMES
117
- // todo extract these options into more suitable place (https://github.com/UnitTestBot/UTBotJava/issues/359)
118
- // do not rewrite display name if already set
119
- && traceTags.execution.displayName.isNullOrBlank()) {
136
+ if (GENERATE_DISPLAY_NAMES ) {
120
137
if (! GENERATE_DISPLAYNAME_FROM_TO_STYLE ) {
121
138
traceTags.execution.displayName = displayName
122
139
} else {
123
140
traceTags.execution.displayName = fromToName
124
141
}
125
142
}
126
- if (GENERATE_NAMES
127
- // todo extract these options into more suitable place (https://github.com/UnitTestBot/UTBotJava/issues/359)
128
- // do not rewrite display name if already set
129
- && traceTags.execution.testMethodName.isNullOrBlank()) {
143
+ if (GENERATE_NAMES ) {
130
144
traceTags.execution.testMethodName = name
131
145
if (nameIndex != 0 ) traceTags.execution.testMethodName + = " _$nameIndex "
132
146
}
@@ -150,6 +164,9 @@ class Summarization(val sourceFile: File?, val invokeDescriptions: List<InvokeDe
150
164
return listOf (UtExecutionCluster (UtClusterInfo (), testCase.executions))
151
165
}
152
166
167
+ private fun getExecutionsWithEmptyPath (testCase : UtTestCase ) =
168
+ testCase.executions.filter { it.path.isEmpty() }
169
+
153
170
/*
154
171
* asts of invokes also included
155
172
* */
0 commit comments