microsoft / vscode-java-test

Run and debug Java test cases in Visual Studio Code.
https://marketplace.visualstudio.com/items?itemName=vscjava.vscode-java-test
Other
295 stars 127 forks source link

Peek view for failed JUnit test has two views randomly #1661

Closed Ao-Last closed 7 months ago

Ao-Last commented 8 months ago

To reproduce,

  1. Using JUnit to perform a test with assert statement. E.g. assertEquals(expected_string, actual_stirng)

  2. If the test failed, the plugin would show a peek view for comparison between the expected and actual.

    image
  3. If run the test again, the comparison view is broken.

    image
  4. Close the popup peek view, and click the red error message nearby, the view is a perfect comparison view.

jdneo commented 8 months ago

Could you share a sample code for this issue?

Ao-Last commented 8 months ago

View1:

image

close the peek view and then click the red character could lead to view2.

View2:

image

I found that with a long string that cannot be displayed in the screen would increase the probability triggering the bug.

Source code:

/*
 * This Java source file was generated by the Gradle 'init' task.
 */
package test_gradle;

public class App {
    public String getGreeting() {
        return "Hello World!jslkfajslkdfjaiosdjfalskdjfklajsdlkfjasiodfjasldkfj;lksdjvm,xchiugbhydafighdansk,vjhnioasdyifpujsldkfjnfcl;asdjfhiosja;fjasdikfjp9asiohjfncli;sdafi9opshalfl;asjdfkljasiopfjasolifjsdlkfcj;aiopdjflisdjfcklsdjnviogasyhgioasdjnlkhnsdaoiyhasiodjflksdjf9iajhasldfjnclksdjha9ioshjuflaidjflask";
    }

    public static void main(String[] args) {
        System.out.println(new App().getGreeting());
    }
}

Test code:

/*
 * This Java source file was generated by the Gradle 'init' task.
 */
package test_gradle;

import org.junit.jupiter.api.Test;
import static org.junit.jupiter.api.Assertions.*;

class AppTest {
    @Test void appHasAGreeting() {
        App classUnderTest = new App();
        assertEquals("Wrong", classUnderTest.getGreeting());
    }
}
jdneo commented 8 months ago

Ok, I guess I got your point.

So, there are two different kinds of different peek views:

You can switch between them in the test history

image

Ao-Last commented 8 months ago

Yes. One of the view will popup as the peek view. Is it undefined?

jdneo commented 8 months ago

On my machine it always shows the diff view. No random behavior is observed.

Ao-Last commented 8 months ago

Click the two "run" button near the method signature multiple times (maybe randomly), the random behavior happened.

image
github-actions[bot] commented 7 months ago

This issue has been closed automatically because it needs more information and has not had recent activity. Please reach out if you have or find the answers we need so that we can investigate further.