Skip to content
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

Unresolved links in the JavaDocs to the nested classes #1361

Closed
amandelpie opened this issue Nov 14, 2022 · 5 comments · Fixed by #1395
Closed

Unresolved links in the JavaDocs to the nested classes #1361

amandelpie opened this issue Nov 14, 2022 · 5 comments · Fixed by #1395
Assignees
Labels
comp-summaries Something related to the method names, code comments and display names generation ctg-bug Issue is a bug

Comments

@amandelpie
Copy link
Collaborator

Description

We generates wrong JavaDocs for Fuzzing Tests for the example with the nested classes

To Reproduce

  1. Run the snippet of code in IntelliJ Idea
  2. Run plugin via runIde
  3. Disable Symbolic in the Settings Panel (Fuzzing = 100 %, Symbolic = 0 %)
  4. Use plugin to generate tests

Snippet of code to generate:

package custom.inner;

public class DeepNested {
    public class Nested1 {
        public class Nested2 {
            public int f(int i) {
                if (i > 0) {
                    return 10;
                }
                return 0;
            }
        }
    }
}

The given tests:

package custom.inner;

import org.junit.jupiter.api.Nested;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.DisplayName;
import custom.inner.DeepNested.Nested1.Nested2;
import custom.inner.DeepNested.Nested1;

import static org.utbot.runtime.utils.java.UtUtils.createInstance;
import static org.junit.jupiter.api.Assertions.assertEquals;

public final class DeepNestedTest {
    ///region Tests for Nested1

    @Nested
    public final class Nested1Test {
        ///region Tests for Nested2

        @Nested
        public final class Nested2Test {
            ///region Test suites for executable custom.inner.DeepNested$Nested1$Nested2.f

            ///region

            /**
             * @utbot.classUnderTest {@link custom.inner.DeepNested.Nested1.Nested2}
             * @utbot.methodUnderTest {@link custom.inner.DeepNested.Nested1.Nested2#f(int)}
             */
            @Test
            @DisplayName("f: i = 0 -> return 0")
            public void testFReturnsZeroWithCornerCase() throws Exception {
                Nested2 nested2 = ((Nested2) createInstance("custom.inner.DeepNested$Nested1$Nested2"));

                int actual = nested2.f(0);

                assertEquals(0, actual);
            }

            /**
             * @utbot.classUnderTest {@link custom.inner.Nested2}
             * @utbot.methodUnderTest {@link custom.inner.Nested2#f(int)}
             */
            @Test
            @DisplayName("f: i = 134217728 (mutated from 0) -> return 10")
            public void testFReturns10() throws Exception {
                Nested2 nested2 = ((Nested2) createInstance("custom.inner.DeepNested$Nested1$Nested2"));

                int actual = nested2.f(134217728);

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

            ///region FUZZER: SUCCESSFUL EXECUTIONS for method f(int)

            /**
             * @utbot.classUnderTest {@link custom.inner.Nested2}
             * @utbot.methodUnderTest {@link custom.inner.Nested2#f(int)}
             */
            @Test
            @DisplayName("f: f: i = 0 -> return 0")
            public void testFReturnsZeroWithCornerCase1() throws Exception {
                Nested2 nested2 = ((Nested2) createInstance("custom.inner.DeepNested$Nested1$Nested2"));

                int actual = nested2.f(0);

                assertEquals(0, actual);
            }

            /**
             * @utbot.classUnderTest {@link custom.inner.Nested2}
             * @utbot.methodUnderTest {@link custom.inner.Nested2#f(int)}
             */
            @Test
            @DisplayName("f: f: i = 134217728 (mutated from 0) -> return 10")
            public void testFReturns101() throws Exception {
                Nested2 nested2 = ((Nested2) createInstance("custom.inner.DeepNested$Nested1$Nested2"));

                int actual = nested2.f(134217728);

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

            ///endregion
        }
        ///endregion
    }
    ///endregion
}

Expected behavior

JavaDocs with the resolved links should be generated.

Actual behavior

Some links don't contain the full path to the nested class, middle information is lost or erased.

Visual proofs (screenshots, logs, images)

image

Should be like on the screen below:

image

@amandelpie amandelpie added the ctg-bug Issue is a bug label Nov 14, 2022
@amandelpie amandelpie added the comp-summaries Something related to the method names, code comments and display names generation label Nov 14, 2022
@korifey korifey moved this to Todo in UTBot Java Nov 14, 2022
@amandelpie amandelpie self-assigned this Nov 14, 2022
@amandelpie amandelpie added this to the 2022.12 Release milestone Nov 14, 2022
@amandelpie
Copy link
Collaborator Author

related to #1359 and #710

@alisevych
Copy link
Member

@amandelpie
Here is one more special case for this issue:

Links to nested Enums are not resolved in Java docs.
That can be verified with org/utbot/examples/enums/ClassWithEnum.java sample.

@amandelpie
Copy link
Collaborator Author

@amandelpie Here is one more special case for this issue:

Links to nested Enums are not resolved in Java docs. That can be verified with org/utbot/examples/enums/ClassWithEnum.java sample.

Strange, but it's not reproduced on the existing master, all links to the enums are resolved correctly @alisevych

@alisevych
Copy link
Member

@amandelpie It is reproducing in IDEA Ultimate 2022.2.3 with the plugin from today's main installed:

image

@alisevych
Copy link
Member

@amandelpie
Links to Enums are resolved correctly
image

Repository owner moved this from Todo to Done in UTBot Java Dec 9, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-summaries Something related to the method names, code comments and display names generation ctg-bug Issue is a bug
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants