Description
Generated tests for ClassWithComplicatedMethods use UtUtils method createInstance,
while there are public constructors.
To Reproduce
- Install UnitTestBot -IU- plugin built from main in IntelliJ IDEA
- Open
utbot-sample module in UTBotJava project
- Generate tests for
ClassWithComplicatedMethods
- Find
createInstance calls in generated tests
Expected behavior
ClassWithComplicatedMethods has public constructors with a and b parameters.
Is it expected that they are used? Only a is used in path constraints.
Actual behavior
createInstance is called in all tests generated with Symbolic execution
Screenshots, logs
///region SYMBOLIC EXECUTION: SUCCESSFUL EXECUTIONS for method applyMethodWithSideEffectAndReturn(int)
/**
* @utbot.classUnderTest {@link ClassWithComplicatedMethods}
* @utbot.methodUnderTest {@link ClassWithComplicatedMethods#applyMethodWithSideEffectAndReturn(int)}
* @utbot.executesCondition {@code (a == 2821): False}
* @utbot.invokes org.utbot.examples.make.symbolic.ClassWithComplicatedMethods#methodWithSideEffect(int)
*/
@Test
@DisplayName("applyMethodWithSideEffectAndReturn: ClassWithComplicatedMethodsMethodWithSideEffect -> return this")
public void testApplyMethodWithSideEffectAndReturn_ANotEquals2821() throws Exception {
ClassWithComplicatedMethods classWithComplicatedMethods = ((ClassWithComplicatedMethods) createInstance("org.utbot.examples.make.symbolic.ClassWithComplicatedMethods"));
classWithComplicatedMethods.a = 15;
ClassWithComplicatedMethods actual = classWithComplicatedMethods.applyMethodWithSideEffectAndReturn(1);
int classWithComplicatedMethodsA = classWithComplicatedMethods.a;
int actualA = actual.a;
assertEquals(classWithComplicatedMethodsA, actualA);
int finalClassWithComplicatedMethodsA = classWithComplicatedMethods.a;
assertEquals(2821, finalClassWithComplicatedMethodsA);
}
///endregion
Environment
IntelliJ IDEA version - Ultimate 2023.2
Project - Gradle
JDK - 17
Description
Generated tests for ClassWithComplicatedMethods use UtUtils method createInstance,
while there are public constructors.
To Reproduce
utbot-samplemodule inUTBotJavaprojectClassWithComplicatedMethodscreateInstancecalls in generated testsExpected behavior
ClassWithComplicatedMethods has public constructors with a and b parameters.
Is it expected that they are used? Only
ais used in path constraints.Actual behavior
createInstance is called in all tests generated with Symbolic execution
Screenshots, logs
Environment
IntelliJ IDEA version - Ultimate 2023.2
Project - Gradle
JDK - 17