File tree Expand file tree Collapse file tree 2 files changed +13
-8
lines changed
utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/constructor Expand file tree Collapse file tree 2 files changed +13
-8
lines changed Original file line number Diff line number Diff line change @@ -234,16 +234,17 @@ internal interface CgContextOwner {
234
234
}
235
235
236
236
fun addExceptionIfNeeded (exception : ClassId ) {
237
- collectedExceptions.forEach {
238
- if (it isSubtypeOf exception) return
239
- }
240
- collectedExceptions.forEach {
241
- if (exception isSubtypeOf it) collectedExceptions.remove(it)
237
+ for (existingException in collectedExceptions) {
238
+ if (exception isSubtypeOf existingException) {
239
+ return
240
+ }
242
241
}
243
242
244
- if (collectedExceptions.add(exception)) {
245
- importIfNeeded(exception)
246
- }
243
+ collectedExceptions
244
+ .removeIf { existingException -> existingException isSubtypeOf exception }
245
+
246
+ collectedExceptions.add(exception)
247
+ importIfNeeded(exception)
247
248
}
248
249
249
250
fun addAnnotation (annotation : CgAnnotation ) {
Original file line number Diff line number Diff line change @@ -131,6 +131,10 @@ internal class CgCallableAccessManagerImpl(val context: CgContext) : CgCallableA
131
131
return
132
132
}
133
133
134
+ if (methodId == getTargetException) {
135
+ addExceptionIfNeeded(Throwable ::class .id)
136
+ }
137
+
134
138
val methodIsUnderTestAndThrowsExplicitly = methodId == currentExecutable
135
139
&& currentExecution?.result is UtExplicitlyThrownException
136
140
val frameworkSupportsAssertThrows = testFramework == Junit5 || testFramework == TestNg
You can’t perform that action at this time.
0 commit comments