Skip to content

Generated tests for collection sorting doesn't contain assertions #1288

Open
@tyuldashev

Description

@tyuldashev

Description

In some cases UTBot generates test which has creation of actual and expected results but not their comparison. Currently I found that It affects usage of sorted, sortedBy, srotedDescending and sortedByDescending.

To Reproduce

Steps to reproduce the behavior:

  1. In UTBot settings set Generated test language to Kotlin
  2. Generate tests for following code
class SortingList {
    fun descending(list: List<Int>) = list.sortedDescending()
}

Expected behavior

Generated tests has assertions

Actual behavior
Generated test looks like that, it has actual and expected results, but they are not compared with each other.

    @Test
    @DisplayName("natural: arg_0 = ListSample()")
    fun testNatural() {
        val listSample = ListSample()
        
        val actual = listSample.natural()
        
        val expected = createInstance("java.util.Arrays\$ArrayList") ?: error("createInstance failed")
    }

Additional context

createInstance("java.util.Arrays\$ArrayList") construction also looks suspicious. Not sure if it's cause of described problem or separated problem.

Metadata

Metadata

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