Skip to content

UtUtils.deepEquals not resolved in generated tests #1255

Closed
@tyuldashev

Description

@tyuldashev

Description

In case user code contains modification of collections UTBot tries to verify it with UtUtils.deepEquals method but it cannot be resolved in tests, so they cannot be compiled and executed.

To Reproduce

Steps to reproduce the behavior:

  1. In UTBot settings set Generated test language to Kotlin
  2. Generate tests for following code
class Listing {
    val list = mutableListOf<String>()
    fun addValue(str:String): List<String> {
        list.add(str)
        return list
    }
}

Expected behavior

Compilable tests are supposed to be generated.

Actual behavior

Generated tests are red and can not be run

import org.utbot.runtime.utils.UtUtils.deepEquals
import org.junit.jupiter.api.Assertions.assertTrue

class PersonTest {
    ///region Test suites for executable examples.introduction.Person.likes
    
    ///region
    
    /**
    @utbot.classUnderTest {@link examples.introduction.Person}
 * @utbot.methodUnderTest {@link examples.introduction.Person#likes(examples.introduction.Person)}
 *  */
    @Test
    @DisplayName("likes: other = Person(String)")
    fun testLikes() {
        val person = Person("")
        val other = Person("")
        
        val actual = (person.likes(other) as ArrayList)
        
        val expected = ArrayList()
        expected.add(other)
        assertTrue(deepEquals(expected, actual))
    }
...

Visual proofs (screenshots, logs, images)

image

Additional context

I assume that problem with ArrayList() is part of #88, so doesn't describe it here

Metadata

Metadata

Assignees

Labels

ctg-bugIssue is a buglang-kotlinIssue is related to Kotlin language support

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions