Skip to content

Missing line separator in a generated kotlin file #842

Open

Description

@CaelmBleidd

Description

When UTBot generates kotlin file with a failing test, there is a missing line separator in it.

To Reproduce

Steps to reproduce the behavior:

Example:

  1. Run any project with runtime error in the code in IntelliJ Idea
  2. Use the plugin to generate tests
  3. Open the generated test

Expected behavior

A line with "/* This test fails because...", line separator and line that fails

Actual behavior

Missing line separator

Visual proofs (screenshots, logs, images)

image

Environment

No specific environment is required.

Additional context

There is no additional context.

Activity

  1. moved this to Todo in UTBot Javaon Sep 2, 2022
  2. tyuldashev commented on Oct 28, 2022

    @tyuldashev
    Collaborator

    There is bigger problem with javadoc formatting, does dedicated issue is required?
    image
    as result displayed as
    image

  3. EgorkaKulikov commented on Nov 11, 2022

    @EgorkaKulikov
    Collaborator

    Actually this issue may be irrelevant because kotlin docs are now disabled.

  4. sofurihafe commented on Nov 11, 2022

    @sofurihafe
    Member

    Just tried to reproduce the problem with the following java & kotlin code samples. The missing line separator is present for both of them.

    Code to generate tests for:
    №1

    public void methodThrowingException1() {
        int[] array = new int[1];
        int a = array[2];
    }
    
    public void methodThrowingException3() {
        int[] array = null;
        int a = array.length;
    }

    №2

    fun methodThrowingException1() {
        val array = Array<Int>(1) { 1 };
        val a = array[2]
    }
    
    fun methodThrowingException2() {
        val array: Array<Int>? = null
        val a = array!![1]
    }

    Generated results:
    №1

    @Test
    fun testMethodThrowingException11() {
        val simpleClass = SimpleClass()
        
        /* This test fails because method [SimpleClass.methodThrowingException1] produces [java.lang.ArrayIndexOutOfBoundsException: Index 2 out of bounds for length 1]
            SimpleClass.methodThrowingException1(SimpleClass.java:4) */
        simpleClass.methodThrowingException1()
    }
    
    @Test
    fun testMethodThrowingException31() {
        val simpleClass = SimpleClass()
        
        /* This test fails because method [SimpleClass.methodThrowingException3] produces [java.lang.NullPointerException]
            SimpleClass.methodThrowingException3(SimpleClass.java:9) */
        simpleClass.methodThrowingException3()
    }

    №2

    @Test
    fun testMethodThrowingException11() {
        val a = A()
        
        /* This test fails because method [A.methodThrowingException1] produces [java.lang.ArrayIndexOutOfBoundsException: Index 2 out of bounds for length 1]
            A.methodThrowingException1(Main.kt:4) */
        a.methodThrowingException1()
    }
    
    @Test
    fun testMethodThrowingException21() {
        val a = A()
        
        /* This test fails because method [A.methodThrowingException2] produces [java.lang.NullPointerException]
            A.methodThrowingException2(Main.kt:9) */
        a.methodThrowingException2()
    }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Labels

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

Type

No type

Projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions