Skip to content

UTBot tries to use internal kotlin.collections.EmptySet object #1284

Open
@tyuldashev

Description

@tyuldashev

Description

When user code has Set as return type then UTBot tries to import internal kotlin.collections.EmptySet to initialize actual value.

To Reproduce

Steps to reproduce the behavior:

  1. In UTBot settings set Generated test language to Kotlin
  2. Generate tests for following code
class EmptySetProblem {
    fun issuesWithEmptyDescription(issues: Set<String>): Set<String> {
        return issues.filter { it.length < 5 }.toSet()
    }
}

Expected behavior

Compilable tests are generated

Actual behavior
Generated tests cannot be executed because code has error

    @Test
    @DisplayName("issuesWithEmptyDescription: issues = test collection")
    fun testIssuesWithEmptyDescription() {
        val emptySetProblem = EmptySetProblem()
        val issues = HashSet()
        issues.add("aqyas")
        issues.add("hxgvr")
        issues.add("aqyas")
        issues.add("yippo")
        issues.add("aqyas")
        
        val actual = (emptySetProblem.issuesWithEmptyDescription(issues) as EmptySet)
        
        val expected = (createInstance("kotlin.collections.EmptySet") as EmptySet)
...

Visual proofs (screenshots, logs, images)
image

Metadata

Metadata

Assignees

Labels

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

Type

No type

Projects

Status

Todo

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions