Skip to content

Commit 0b82bcb

Browse files
committed
Revert getTargetException check
1 parent eebd835 commit 0b82bcb

File tree

2 files changed

+13
-8
lines changed

2 files changed

+13
-8
lines changed

utbot-framework/src/main/kotlin/org/utbot/framework/codegen/model/constructor/context/CgContext.kt

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -234,16 +234,17 @@ internal interface CgContextOwner {
234234
}
235235

236236
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+
}
242241
}
243242

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)
247248
}
248249

249250
fun addAnnotation(annotation: CgAnnotation) {

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,10 @@ internal class CgCallableAccessManagerImpl(val context: CgContext) : CgCallableA
131131
return
132132
}
133133

134+
if (methodId == getTargetException) {
135+
addExceptionIfNeeded(Throwable::class.id)
136+
}
137+
134138
val methodIsUnderTestAndThrowsExplicitly = methodId == currentExecutable
135139
&& currentExecution?.result is UtExplicitlyThrownException
136140
val frameworkSupportsAssertThrows = testFramework == Junit5 || testFramework == TestNg

0 commit comments

Comments
 (0)