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

Variable objectType with Class is used but not created #2422

Open
alisevych opened this issue Jul 17, 2023 · 2 comments
Open

Variable objectType with Class is used but not created #2422

alisevych opened this issue Jul 17, 2023 · 2 comments
Assignees
Labels
comp-codegen Issue is related to code generator comp-spring Issue is related to Spring projects support comp-symbolic-engine Issue is related to the symbolic execution engine ctg-bug Issue is a bug

Comments

@alisevych
Copy link
Member

alisevych commented Jul 17, 2023

Description

Variable objectType with Class is used but not created.

To Reproduce

  1. Install UnitTestBot plugin built from main in IntelliJ IDEA
  2. Open sm***t project
  3. Press Ctrl+Shift+N, input rdi
  4. Generate tests for all methods of the class with @SpringBootApplication and Unit tests selected

Expected behavior

  1. Variable objectType is initialized with object's class.
    Or Object.class should be used instead.
  2. Assert of finalObjectType is (probably) expected.

Actual behavior

Variable objectType with Class is used to pass the Class of the first object.
finalObjectType is created, but not checked

Screenshots, logs

    ///region OTHER: EXPLICITLY THROWN UNCHECKED EXCEPTIONS for method query(java.lang.Object, java.lang.Class)

    @Test
    public void testQuery1() {
        Object value = new Object();

        assertThrows(IllegalArgumentException.class, () -> rdi.query(value, Object.class));

        Class finalObjectType = objectType;

    }
    ///endregion

Environment

IntelliJ IDEA version - Ultimate 2023.1.4
Project - Maven
JDK - 1.8

@alisevych alisevych added ctg-bug Issue is a bug comp-codegen Issue is related to code generator comp-symbolic-engine Issue is related to the symbolic execution engine comp-spring Issue is related to Spring projects support labels Jul 17, 2023
@alisevych alisevych added this to the Spring Phase 4 milestone Jul 17, 2023
@EgorkaKulikov
Copy link
Collaborator

@alisevych Can you still reproduce it?

@alisevych alisevych self-assigned this Aug 4, 2023
@alisevych
Copy link
Member Author

alisevych commented Aug 4, 2023

@EgorkaKulikov Partially. Now the following test is generated - on latest main in IDEA 2023.2:

    @Test
    public void testQuery3() {
        Object value = new Object();
        Class clazz = Object.class;

        assertThrows(IllegalArgumentException.class, () -> rdi.query(value, clazz));

        Class finalClazz = clazz;

}

@alisevych alisevych removed their assignment Aug 11, 2023
@alisevych alisevych removed this from the Spring Phase 4 milestone Oct 2, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-codegen Issue is related to code generator comp-spring Issue is related to Spring projects support comp-symbolic-engine Issue is related to the symbolic execution engine ctg-bug Issue is a bug
Projects
Status: Todo
Development

No branches or pull requests

2 participants