Skip to content

Compare returning expected and actual Stream #1046

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

Open
alisevych opened this issue Sep 30, 2022 · 2 comments
Open

Compare returning expected and actual Stream #1046

alisevych opened this issue Sep 30, 2022 · 2 comments
Labels
comp-codegen Issue is related to code generator ctg-bug Issue is a bug lang-java Issue is related to Java support

Comments

@alisevych
Copy link
Member

alisevych commented Sep 30, 2022

Description

Tests on methods returning Stream contain actual and expected results, but do not have any assertions to compare them.

To Reproduce

  1. Run the 'UTBotJava' project in IntelliJ Idea 2022.1.4
  2. Install one of the latest from main branch
  3. Open test generation dialog for utbot-sample/src/main/java/org/utbot/examples/stream/BaseStreamExample.java
  4. Select returningStreamExample method
  5. click Generate Tests
  6. check generated tests

Expected behavior

Need to compare expected and actual results for Streams in tests.

Actual behavior

There are actual and expected Objects generated containing Streams. But they are not compared.

Visual proofs (screenshots, logs, images)

package org.utbot.examples.stream;

import org.junit.jupiter.api.Test;
import org.junit.jupiter.api.DisplayName;

import java.util.ArrayList;
import java.util.List;

import static org.utbot.runtime.utils.UtUtils.createInstance;

public class BaseStreamExampleTest {
    ///region Test suites for executable org.utbot.examples.stream.BaseStreamExample.returningStreamExample

    ///region SYMBOLIC EXECUTION ENGINE: SUCCESSFUL EXECUTIONS for method returningStreamExample(java.util.List)

    /**
     * @utbot.classUnderTest {@link BaseStreamExample}
     * @utbot.methodUnderTest {@link BaseStreamExample#returningStreamExample(List)}
     * @utbot.executesCondition {@code (list.isEmpty()): True}
     * @utbot.invokes {@code {@link List#stream()}}
     * @utbot.returnsFrom {@code return list.stream();}
     */
    @Test
    @DisplayName("returningStreamExample: list.isEmpty() : True -> return list.stream()")
    public void testReturningStreamExample_ListIsEmpty() throws Exception {
        BaseStreamExample baseStreamExample = new BaseStreamExample();
        ArrayList list = new ArrayList();

        Object actual = baseStreamExample.returningStreamExample(list);

        Object expected = createInstance("java.util.stream.ReferencePipeline$Head");
    }

    /**
     * @utbot.classUnderTest {@link BaseStreamExample}
     * @utbot.methodUnderTest {@link BaseStreamExample#returningStreamExample(List)}
     * @utbot.executesCondition {@code (list.isEmpty()): False}
     * @utbot.invokes {@code {@link List#stream()}}
     * @utbot.returnsFrom {@code return list.stream();}
     */
    @Test
    @DisplayName("returningStreamExample: list.isEmpty() : False -> return list.stream()")
    public void testReturningStreamExample_NotListIsEmpty() throws Exception {
        BaseStreamExample baseStreamExample = new BaseStreamExample();
        ArrayList list = new ArrayList();
        list.add(null);
        list.add(null);
        list.add(null);
        list.add(null);
        list.add(null);
        list.add(null);
        list.add(null);
        list.add(null);
        list.add(null);
        list.add(null);

        Object actual = baseStreamExample.returningStreamExample(list);

        Object expected = createInstance("java.util.stream.ReferencePipeline$Head");
    }
    ///endregion

    ///endregion
}

Environment

Windows 10 Pro
Gradle
JDK 11

Additional context

Probably related to #1034

Same for DoubleStreamExample.returningStreamExample

@alisevych alisevych added the ctg-bug Issue is a bug label Sep 30, 2022
@alisevych alisevych changed the title Compare returning expected and actual Stream when returned from a method Compare returning expected and actual Stream Sep 30, 2022
@korifey korifey moved this to Todo in UTBot Java Sep 30, 2022
@alisevych
Copy link
Member Author

@Damtev @EgorkaKulikov
Could you please share your view on the generated tests on Streams? And on Functional interfaces too?
It seems that we need to add some verification of user's code. Comparing objects in a Stream or making some other checks.

@alisevych
Copy link
Member Author

@Damtev Please pay attention that in second test expected field is not equal to actual : it is empty.

@alisevych alisevych added comp-codegen Issue is related to code generator lang-java Issue is related to Java support labels Feb 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
comp-codegen Issue is related to code generator ctg-bug Issue is a bug lang-java Issue is related to Java support
Projects
Status: Todo
Development

No branches or pull requests

1 participant