Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix assertions #1096

Merged
merged 2 commits into from
Oct 5, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,13 @@ object UtSettings : AbstractSettings(
*/
var treatOverflowAsError: Boolean by getBooleanProperty(false)

/**
* Generate tests that treat assertions as error suits.
*
* True by default.
*/
var treatAssertAsErrorSuit: Boolean by getBooleanProperty(true)

/**
* Instrument all classes before start
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,10 @@ import org.utbot.tests.infrastructure.UtValueTestCaseChecker
import org.utbot.tests.infrastructure.isException
import org.utbot.testcheckers.eq

class JavaAssertTest : UtValueTestCaseChecker(testClass = JavaAssert::class){
class JavaAssertTest : UtValueTestCaseChecker(
testClass = JavaAssert::class,
testCodeGeneration = false
) {
@Test
fun testAssertPositive() {
checkWithException(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,7 @@ import org.utbot.summary.SummarySentenceConstants.TAB
import java.lang.reflect.InvocationTargetException
import java.security.AccessControlException
import java.lang.reflect.ParameterizedType
import org.utbot.framework.UtSettings

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

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

val exceptionRequiresAssert = exception !is RuntimeException || runtimeExceptionTestsBehaviour == PASS
val exceptionIsExplicit = execution.result is UtExplicitlyThrownException
Expand Down