GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Unnecessary reflection used for val properties that can be set via constructor · Issue #1190 · UnitTestBot/UTBotJava

Unnecessary reflection used for val properties that can be set via constructor #1190

New issue
Copy link
New issue
Copy link
Closed
#1240
Closed
Unnecessary reflection used for val properties that can be set via constructor#1190
#1240
Copy link
Assignees
volivan239
Labels
comp-codegenIssue is related to code generatorIssue is related to code generatorctg-bugIssue is a bugIssue is a buglang-kotlinIssue is related to Kotlin language supportIssue is related to Kotlin language support

Description

@volivan239
volivan239
opened on Oct 19, 2022
Issue body actions

Description

If constructor has a val property, codegen doesn't use this constructor but instead instantiates class via reflection although it can normally be done without it.

To Reproduce

Launch action on the following class:

class CustomClass(val x: Int) {
    fun f(): Int {
        return x
    }
}

Expected behavior

Correct tests are generated, reflection is not used at all.

Actual behavior

Generated tests contain reflection usage.

Visual proofs (screenshots, logs, images)

One of the generated tests:

@Test
fun testF1() {
    val customClass = (createInstance("CustomClass") as CustomClass)
    setField(customClass, "CustomClass", "x", -255)
    
    val actual = customClass.f()
      
    assertEquals(-255, actual)
}

Activity

  1. volivan239
    added
    ctg-bugIssue is a bugIssue is a bug
    comp-codegenIssue is related to code generatorIssue is related to code generator
    on Oct 19, 2022
  2. volivan239
    self-assigned this
    on Oct 19, 2022
  3. korifey
    added this to UTBot Javaon Oct 19, 2022
  4. korifey
    moved this to Todo in UTBot Javaon Oct 19, 2022
  5. volivan239
    added
    lang-kotlinIssue is related to Kotlin language supportIssue is related to Kotlin language support
    on Oct 28, 2022
  6. volivan239
    added a commit that references this issue on Oct 31, 2022

    Construct assemble models for classes with val-properties in construc…

    15d2b4f
  7. volivan239
    closed this as completedin #1240on Oct 31, 2022
  8. Repository owner moved this from Todo to Done in UTBot Javaon Oct 31, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

  • @volivan239
    volivan239

Labels

comp-codegenIssue is related to code generatorIssue is related to code generatorctg-bugIssue is a bugIssue is a buglang-kotlinIssue is related to Kotlin language supportIssue is related to Kotlin language support

Type

No type

Projects

  • UTBot Java
    Status
    Done
    Show more project fields

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions

You are visitor 01402520 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.