Skip to content

UtUtils class is not generated with the first UTBot test generation #879

Closed as not planned
@alisevych

Description

@alisevych

Description

UtUtils.deepEquals is used in generated CommonMocksExampleTest but not created.
Second UTBot execution generated UtUtils class.

To Reproduce

Steps to reproduce the behavior:

  1. Open the utbot-sample/src/main/java/org/utbot/examples/mock/CommonMocksExample.java file
  2. Generate tests in utbot-sample test source root
    with "Other packages: Mockito" and "Mockito static mocking" options
  3. Open the generated test

Expected behavior

UtUtils class is supposed to be generated when used.

Actual behavior

UtUtils class is missed.
Import UtUtils.deepEquals is not found.
Tests are not compiling.
Second test generation for the same class creates UtUtils class.

Visual proofs (screenshots, logs, images)

There is the following strings in the generated test class:

import static org.utbot.runtime.utils.UtUtils.deepEquals;

    @Test
    @DisplayName("nextValue: node.next == node : True -> return node")
    public void testNextValue_NodeNextEqualsNode() {
        CommonMocksExample commonMocksExample = new CommonMocksExample();
        RecursiveTypeClass nodeMock = mock(RecursiveTypeClass.class);
        nodeMock.next = nodeMock;

        RecursiveTypeClass actual = commonMocksExample.nextValue(nodeMock);

        assertTrue(deepEquals(nodeMock, actual));
        int nodeMockValue = nodeMock.value;
        int actualValue = actual.value;
        assertEquals(nodeMockValue, actualValue);

    }

image

Environment

Windows 10 Pro
UTBotJava project
JDK 11 is used

Additional context

Same for code when UtUtils.createInstance is used in the generated test.

Metadata

Metadata

Assignees

Labels

ctg-bugIssue is a bug

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions