Skip to content

No validation of a Collection changing passed as input parameter #2372

Open
@alisevych

Description

@alisevych

Description

No validation of a Collection of elements in Spring No configuration test

To Reproduce

  1. Install UnitTestBot plugin built from main in IntelliJ IDEA 2023.1.3
  2. Open spring-petclinic project
  3. Generate tests for Owner class
  4. Check successful test on (pet.isNew()): True branch

Expected behavior

Assert added Pet exists in owner.pets field

Actual behavior

List of null values is created. No checks for the List are made.

Screenshots, logs

/**
	 * @utbot.classUnderTest {@link Owner}
	 * @utbot.methodUnderTest {@link Owner#addPet(Pet)}
	 * @utbot.executesCondition {@code (pet.isNew()): True}
	 * @utbot.invokes {@link Owner#getPets()}
	 * @utbot.invokes {@link java.util.List#add(Object)}
	 */
	@Test
	@DisplayName("addPet: pet.isNew() : True -> ListAdd")
	public void testAddPet_PetIsNew() {
		ArrayList arrayList = new ArrayList();
		arrayList.add(null);
		arrayList.add(null);
		arrayList.add(null);
		Pet petMock1 = mock(Pet.class);
		(when(petMock1.isNew())).thenReturn(true);

		owner.addPet(petMock1);
	}

Environment

IntelliJ IDEA version - Ultimate 2023.1.3
Project - Gradle
JDK - 17

Metadata

Metadata

Assignees

No one assigned

    Labels

    comp-codegenIssue is related to code generatorcomp-symbolic-engineIssue is related to the symbolic execution enginectg-bugIssue is a bug

    Type

    No type

    Projects

    Status

    Todo

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions