Skip to content

Tests for autogenerated Kotlin getters/setters shouldn't be generated in cli and contest estimator #1338

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
volivan239 opened this issue Nov 9, 2022 · 0 comments · Fixed by #1341
Assignees
Labels
comp-cli Issue related to CLI ctg-bug Issue is a bug lang-kotlin Issue is related to Kotlin language support

Comments

@volivan239
Copy link
Collaborator

volivan239 commented Nov 9, 2022

Description

We don't generate tests for autogenerated Kotlin getters/setters in plugin, we shouldn't do this in cli/contest estimator as well.

To Reproduce

Launch UtBot from cli for the following class:

class CheckedAddition(var x: Int) {
    fun addWithCheck(y: Int): Int? {
        val res = x.toLong() + y.toLong()
        if (res >= Int.MIN_VALUE && res <= Int.MAX_VALUE) {
            this.x = res.toInt()
            return res.toInt()
        }
        return null
    }
}

Expected behavior

Correct tests are generated

Actual behavior

UtBot tries to generate tests for setX() and getX() and produce incorrect tests:

Visual proofs (screenshots, logs, images)

@Test
fun testGetX1() {
    val checkedAddition = CheckedAddition(1409199696)
    
    val actual = checkedAddition.getX()
    
    assertEquals(1409199696, actual)
}

Additional context

I think this should be changed in a way similar to #1192

@volivan239 volivan239 added ctg-bug Issue is a bug comp-cli Issue related to CLI lang-kotlin Issue is related to Kotlin language support labels Nov 9, 2022
@volivan239 volivan239 self-assigned this Nov 9, 2022
@korifey korifey moved this to Todo in UTBot Java Nov 9, 2022
Repository owner moved this from Todo to Done in UTBot Java Nov 11, 2022
@alisevych alisevych added this to the 2022.12 Release milestone Nov 30, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-cli Issue related to CLI ctg-bug Issue is a bug lang-kotlin Issue is related to Kotlin language support
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants