Skip to content

Integration tests in utbot-framework fail when assert is used in the Java code #538

Closed
@dtim

Description

@dtim

Description

Symbolic engine correctly generates test cases for branches in Java code that throw java.lang.AssertionError when the assert statement is present in the method under test. At the same time, integration tests fail, as assertions are disabled when the generated test code is run.

To Reproduce

This is an infrastructure-related issue, end users probably will not see it.

To reproduce the bug, create and run a unit test for utbot-framework module whose Java code contains an assert statement.

Test in Kotlin:

@Test
fun testCopyColors() {
    check(
        EnumCollections::copyColors,
        ignoreExecutionsNumber,
        { source, result -> source.isEmpty() && result != null && result.isEmpty() },
        { source, result -> source.isNotEmpty() && result != null && result.isNotEmpty() },
        coverage = FullWithAssumptions(assumeCallsNumber = 1)
    )
}

Method under test in Java:

class EnumCollections {

    // Other methods

    public List<Color> copyColors(@NotNull List<Color> source) {
        LinkedList<Color> result = new LinkedList<>();
        for (Color color : source) {
            assert color != null;
            result.add(color);
        }
        return result;
    }

    // Other methods
}

Expected behavior

Both the test and integration test should pass.

Actual behavior

The test itself should pass, but the integration test should fail with the error message that the assertion is expected but has never been thrown.

Visual proofs (screenshots, logs, images)

image

Environment

Issue does not depend on the environment.

Additional context

No additional context.

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions