UnitTestBot / UTBotJava

Automated unit test generation and precise code analysis for Java
Apache License 2.0
137 stars 43 forks source link

Mock for LocalDate is created with same variable name as mock for PetType #2638

Closed alisevych closed 11 months ago

alisevych commented 1 year ago

Description

There are two variables with name petTypeMock created in Unit tests for Pet

To Reproduce

  1. Install -IU- UnitTestBot plugin in IntelliJ IDEA
  2. Open spring-petclinic
  3. Generate Unit tests for Pet with PetClinicApplication / No Configuration

Expected behavior

No mock for LocalDate is expected. Variables for mocks should be with unique consistent names. Tests should be compiled.

Actual behavior

There is mock for LocalDate. There are two variables with name petTypeMock. Tests are not compiling.

Screenshots, logs

image

image

Environment

IntelliJ IDEA version - Community 2023.2 Project - Maven JDK - 17

EgorkaKulikov commented 1 year ago

It is a pity that this bug reproduced again. We have tried to fix it at least five times.

The general problem is that we do not have unique identifiers of UtModels in the whole test class, just per execution. It causes problems when we need to group all models related to current class variable in Spring. Although we introduced so-called UtmodelWrapper and managed to fix the problem in 99,9% situations, it is not still advanced.

Hope it is a really seldom situation and users will not face it.