Closed
Description
Description
assertNull is applied to the method returned value, while it's method is mocked.
assertEquals to exact value is expected.
To Reproduce
- Install -IU- UnitTestBot plugin in IntelliJ IDEA
- Open
spring-petclinic
- Set Fuzzing 100% mode
- Generate
Unit tests
forPetTypeFormatter
withPetClinicApplication
configuration - Run the tests
Expected behavior
Method PetType$getName()
is mocked with exact return value.
assertEquals
for the actualName
is expected.
Actual behavior
There is failing assertNull
for actualName
in successful test.
Screenshots, logs
@Test
@DisplayName("parse: text = 'XZ', locale = Locale(String, String, String)")
public void testParseWithNonEmptyString() throws ParseException {
ArrayList arrayList = new ArrayList();
PetType petTypeMock = mock(PetType.class);
(when(petTypeMock.getName())).thenReturn("XZ");
arrayList.add(petTypeMock);
(when(ownerRepositoryMock.findPetTypes())).thenReturn(arrayList);
Locale locale = new Locale("\n\t\r", "#$\\\"'", "#$\\\"'");
PetType actual = petTypeFormatter.parse("XZ", locale);
String actualName = actual.getName();
assertNull(actualName);
Integer actualId = actual.getId();
assertNull(actualId);
}
Environment
IntelliJ IDEA version - Community 2023.2
Project - Maven
JDK - 17
Metadata
Metadata
Assignees
Type
Projects
Status
Done