Skip to content

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

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

Closed
dtim opened this issue Jul 15, 2022 · 0 comments · Fixed by #539
Closed

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

dtim opened this issue Jul 15, 2022 · 0 comments · Fixed by #539
Assignees

Comments

@dtim
Copy link
Collaborator

dtim commented Jul 15, 2022

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.

@korifey korifey moved this to Todo in UTBot Java Jul 15, 2022
@dtim dtim self-assigned this Jul 15, 2022
@dtim dtim closed this as completed in #539 Jul 15, 2022
Repository owner moved this from Todo to Done in UTBot Java Jul 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant