Skip to content

Hanging tests duplicates are not minimized #2130

Open
@alisevych

Description

@alisevych

Description

Hanging tests duplicates are not minimized.
There are two identical tests: one generated by Fuzzing, one by Symbolic engine (when default or some custom mode is used).

To Reproduce

  1. Open/create a project in IntelliJ Idea
  2. Install one of the latest plugins built from main
  3. In Settings -> Tools -> UnitTestBot set Fuzzing + Symbolic generation mode
  4. Check Hanging test timeout (1000 ms by default)
  5. Generate tests for the following code:
    public void sleep() throws InterruptedException {
        Thread.sleep(5000);
    }

Expected behavior

One test on timeout should be present in the resulting test class.

Actual behavior

There are two identical tests in the test class.

Visual proofs (screenshots, logs, images)

    ///region SYMBOLIC EXECUTION: TIMEOUTS for method sleep()

    /**
     * @utbot.classUnderTest {@link TimeoutTest}
     * @utbot.methodUnderTest {@link TimeoutTest#sleep()}
     * @utbot.invokes {@link Thread#sleep(long)}
     */
    @Test
    @DisplayName("sleep:  -> TimeoutExceeded")
    @org.junit.jupiter.api.Timeout(value = 1000L, unit = TimeUnit.MILLISECONDS)
    public void testSleep_ThreadSleep() throws InterruptedException {
        TimeoutTest timeoutTest = new TimeoutTest();
        
        /* This execution may take longer than the 1000 ms timeout
         and therefore fail due to exceeding the timeout. */
        assertTimeoutPreemptively(Duration.ofMillis(1000L), () -> timeoutTest.sleep());
    }
    ///endregion

    ///region FUZZER: TIMEOUTS for method sleep()

    /**
     * @utbot.classUnderTest {@link TimeoutTest}
     * @utbot.methodUnderTest {@link TimeoutTest#sleep()}
     */
    @Test
    @DisplayName("sleep: ")
    @org.junit.jupiter.api.Timeout(value = 1000L, unit = TimeUnit.MILLISECONDS)
    public void testSleep() throws InterruptedException {
        TimeoutTest timeoutTest = new TimeoutTest();
        
        /* This execution may take longer than the 1000 ms timeout
         and therefore fail due to exceeding the timeout. */
        assertTimeoutPreemptively(Duration.ofMillis(1000L), () -> timeoutTest.sleep());
    }
    ///endregion

Environment

IntelliJ IDEA 2022.3 / 2023.1

Metadata

Metadata

Assignees

No one assigned

    Labels

    comp-minimizerIssue is related to Minimization phasectg-bugIssue is a bug

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions