Skip to content

Tests on OverflowExamples should fail when Treat overflows as errors #1377

Open
@alisevych

Description

@alisevych

Description

Tests generated by Symbolic Execution for OverflowExamples with Treat overflows as errors option on - are supposed to fail with ArithmeticException, but they are passing.

To Reproduce

  1. Install one of the latest plugin build from main in IDEA
  2. Run the 'UTBotJava' project in IntelliJ Idea
  3. Set Overflow detection to Treat overflows as errors:

image

  1. Use plugin to generate tests for the sample org.utbot.examples.math.OverflowExamples with Mocks off:

image

  1. Find ///region SYMBOLIC EXECUTION: OVERFLOWS for method intOverflow(int, int) in the generated test

Expected behavior

Test is supposed to fail with ArithmeticException

Actual behavior

The test has comment that it produces AithmeticException, but it actually pass.

Visual proofs (screenshots, logs, images)

    ///region SYMBOLIC EXECUTION: OVERFLOWS for method intSubOverflow(int, int)

    /**
     * @utbot.classUnderTest {@link OverflowExamples}
     * @utbot.methodUnderTest {@link OverflowExamples#intSubOverflow(int, int)}
     * @utbot.throwsException {@link ArithmeticException} in: return x - y;
     */
    @Test
    @DisplayName("intSubOverflow: return x - y : True -> ThrowArithmeticException")
    public void testIntSubOverflow_ThrowArithmeticException() {
        OverflowExamples overflowExamples = new OverflowExamples();

        /* This test fails because method [org.utbot.examples.math.OverflowExamples.intSubOverflow] produces [java.lang.ArithmeticException: int  -  overflow] */
        overflowExamples.intSubOverflow(1426620925, -1610612736);
    }
    ///endregion

Environment

Windows 10 Pro
IntelliJ IDEA 2022.2.3

Additional context

There are 15 tests generated for OverflowExamples with the same behavior.

Metadata

Metadata

Assignees

Labels

comp-codegenIssue is related to code generatorctg-bugIssue is a bug

Type

No type

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions