Description
If a method returns an anonymous class, the generated test method contains actual and expected, but doesn't assert them to be equal.
To Reproduce
- Run a project in IntelliJ Idea 2022.1.4 with one of the latest plugin builds from main branch
- Add the following code:
publicclassA {
publicinterfaceDriver {
publicintgetNumber(intn);
}
publicDrivergetDriver() {
returnnewDriver() {
@OverridepublicintgetNumber(intn) {
return2 * n - 1 ;
}
};
}
}- Use plugin to generate tests for getDriver() method.
- Open the generated test
Expected behavior
Test is supposed to contain assert of expected and actual value.
Actual behavior
Test contains actual and expected fields, but there is no assertion.
Visual proofs (screenshots, logs, images)
importorg.junit.jupiter.api.Test;
importorg.junit.jupiter.api.DisplayName;
importstaticorg.utbot.runtime.utils.UtUtils.createInstance;
importstaticorg.utbot.runtime.utils.UtUtils.setField;
publicclassATest {
///region Test suites for executable A.getDriver///region FUZZER: SUCCESSFUL EXECUTIONS for method getDriver()@Test@DisplayName("getDriver: arg_0 = A()")
publicvoidtestGetDriver() throwsException {
Aa = newA();
A.Driveractual = a.getDriver();
A.Driverexpected = ((A.Driver) createInstance("A$1"));
setField(expected, "A$1", "this$0", a);
}
///endregion///endregion
}Environment
Windows 10 Pro
JDK 8
Additional context
The same issue can be seen for generating tests for the following code:
publicclassA {
publicinta, b = 10;
publicList<Integer> integerStream (intc) {
returnArrays.asList(a, b, c);
}
}
Description
If a method returns an anonymous class, the generated test method contains actual and expected, but doesn't assert them to be equal.
To Reproduce
Expected behavior
Test is supposed to contain assert of expected and actual value.
Actual behavior
Test contains actual and expected fields, but there is no assertion.
Visual proofs (screenshots, logs, images)
Environment
Windows 10 Pro
JDK 8
Additional context
The same issue can be seen for generating tests for the following code: