Skip to content

Setting maxTestsPerMethod is ignored #1297

@alisevych

Description

@alisevych

Description

With new functionality:

When maxTestsPerMethod=1 is set test generation for ExceptionExamples is made with default settings.
There are 2 tests generated in a region, 3 tests generated per method.

To Reproduce

  1. In ~/.utbot/settings.properties: set maxTestsPerMethod=1
  2. Install latest build from main into IDEA 2022.2.3
  3. Open UTBotJava project
  4. Generate tests with 95% Symbolic execution for ExceptionExamples#initAnArray(int)

Expected behavior

There should be only 1 test per method generated.

Actual behavior

There are up to 3 tests per method generated, including 2 in the same region.

Visual proofs (screenshots, logs, images)

    ///region Test suites for executable org.utbot.examples.exceptions.ExceptionExamples.initAnArray

    ///region FUZZER: SUCCESSFUL EXECUTIONS for method initAnArray(int)
    /// Actual number of generated tests (3) exceeds per-method limit (1)
    /// The limit can be configured in '{HOME_DIR}/.utbot/settings.properties' with 'maxTestsPerMethod' property

    /**
     * @utbot.classUnderTest {@link ExceptionExamples}
     * @utbot.methodUnderTest {@link ExceptionExamples#initAnArray(int)}
     */
    @Test
    @DisplayName("initAnArray: n = 0 -> return -3")
    public void testInitAnArrayWithCornerCase() {
        ExceptionExamples exceptionExamples = new ExceptionExamples();

        int actual = exceptionExamples.initAnArray(0);

        assertEquals(-3, actual);
    }
    ///endregion

    ///region FUZZER: EXPLICITLY_THROWN_UNCHECKED_EXCEPTIONS for method initAnArray(int)

    /**
     * @utbot.classUnderTest {@link ExceptionExamples}
     * @utbot.methodUnderTest {@link ExceptionExamples#initAnArray(int)}
     */
    @Test
    @DisplayName("initAnArray: n = Int.MAX_VALUE -> throw OutOfMemoryError")
    public void testInitAnArrayThrowsOOMEWithCornerCase() {
        ExceptionExamples exceptionExamples = new ExceptionExamples();

        assertThrows(OutOfMemoryError.class, () -> exceptionExamples.initAnArray(Integer.MAX_VALUE));
    }
    ///endregion

    ///endregion

    ///region Test suites for executable org.utbot.examples.exceptions.ExceptionExamples.nestedExceptions

    ///region FUZZER: SUCCESSFUL EXECUTIONS for method nestedExceptions(int)
    /// Actual number of generated tests (2) exceeds per-method limit (1)
    /// The limit can be configured in '{HOME_DIR}/.utbot/settings.properties' with 'maxTestsPerMethod' property

    /**
     * @utbot.classUnderTest {@link ExceptionExamples}
     * @utbot.methodUnderTest {@link ExceptionExamples#nestedExceptions(int)}
     */
    @Test
    @DisplayName("nestedExceptions: i > 0 -> return 100")
    public void testNestedExceptionsReturns100() {
        ExceptionExamples exceptionExamples = new ExceptionExamples();

        int actual = exceptionExamples.nestedExceptions(1);

        assertEquals(100, actual);
    }
    ///endregion

    ///endregion

Environment

Windows 10 Pro
IntelliJ IDEA 2022.2.3

Related to #1235

Metadata

Metadata

Labels

ctg-bugIssue is a bug

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions