Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 775a38b

Browse files
SBOne-Kenobidenis-fokin
authored andcommitted
Fix assertions (#1096)
(cherry picked from commit 677c15c)
1 parent d5ae1fc commit 775a38b

File tree

3 files changed

+13
-1
lines changed

3 files changed

+13
-1
lines changed

‎utbot-framework-api/src/main/kotlin/org/utbot/framework/UtSettings.kt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,13 @@ object UtSettings : AbstractSettings(
263263
*/
264264
var treatOverflowAsError: Boolean by getBooleanProperty(false)
265265

266+
/**
267+
* Generate tests that treat assertions as error suits.
268+
*
269+
* True by default.
270+
*/
271+
var treatAssertAsErrorSuit: Boolean by getBooleanProperty(true)
272+
266273
/**
267274
* Instrument all classes before start
268275
*/

‎utbot-framework-test/src/test/kotlin/org/utbot/examples/codegen/JavaAssertTest.kt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,10 @@ import org.utbot.tests.infrastructure.UtValueTestCaseChecker
55
import org.utbot.tests.infrastructure.isException
66
import org.utbot.testcheckers.eq
77

8-
class JavaAssertTest : UtValueTestCaseChecker(testClass = JavaAssert::class){
8+
class JavaAssertTest : UtValueTestCaseChecker(
9+
testClass = JavaAssert::class,
10+
testCodeGeneration = false
11+
) {
912
@Test
1013
fun testAssertPositive() {
1114
checkWithException(

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -144,6 +144,7 @@ import org.utbot.summary.SummarySentenceConstants.TAB
144144
import java.lang.reflect.InvocationTargetException
145145
import java.security.AccessControlException
146146
import java.lang.reflect.ParameterizedType
147+
import org.utbot.framework.UtSettings
147148

148149
private const val DEEP_EQUALS_MAX_DEPTH = 5 // TODO move it to plugin settings?
149150

@@ -361,6 +362,7 @@ internal class CgMethodConstructor(val context: CgContext) : CgContextOwner by c
361362
if (exception is AccessControlException) return false
362363
// tests with timeout or crash should be processed differently
363364
if (exception is TimeoutException || exception is ConcreteExecutionFailureException) return false
365+
if (UtSettings.treatAssertAsErrorSuit && exception is AssertionError) return false
364366

365367
val exceptionRequiresAssert = exception !is RuntimeException || runtimeExceptionTestsBehaviour == PASS
366368
val exceptionIsExplicit = execution.result is UtExplicitlyThrownException

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /