Skip to content

Engine doesn't cover branch instanceof String #957

Open
@SBOne-Kenobi

Description

@SBOne-Kenobi

Description

Engine generates 1 execution for this method, but doesn't cover throw statement.

public static void charSeqIsNotString(CharSequence cs) {
    if (cs instanceof String) {
        throw new IllegalStateException("CharSequence must be not String!");
    }
}

To Reproduce

Steps to reproduce the behavior:

Steps to reproduce the behavior:

  1. Create the mentioned method
  2. Make sure that fuzzing turned of (Tools -> UnitTestBot -> Code analysis, toggle must be in the rightest position)
  3. Use plugin to generate tests
  4. Open the generated test
  5. Run tests with coverage

Expected behavior

2 tests are supposed to be generated witch cover all statements.

Actual behavior

1 test generated that don't covers throw statement.

Visual proofs (screenshots, logs, images)

image

Additional context

This bug is a part of issue #820

Activity

self-assigned this
on Sep 19, 2022
moved this to Todo in UTBot Javaon Sep 19, 2022
linked a pull request that will close this issue on Sep 19, 2022
moved this from Todo to In Progress in UTBot Javaon Sep 20, 2022
moved this from In Progress to Done in UTBot Javaon Oct 20, 2022
alisevych

alisevych commented on Jun 29, 2023

@alisevych
Member

Now one test is generating that covers instanceOf branch.
@CaelmBleidd Can you please advise if symbolic engine should cover the case that condition is false?

CaelmBleidd

CaelmBleidd commented on Jun 29, 2023

@CaelmBleidd
Member

If the engine covers only one branch where an object is of String type and doesn't cover other subtypes of CharSequence, it is OK (at least, it is known behaviour). It happens because all CharSequence are treated as strings, therefore, the negation of this makes all the branches with it unreachable.

So, we know about this behaviour, it is not what we want in the future, but it is too complicated to fix for now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

comp-symbolic-engineIssue is related to the symbolic execution enginectg-bugIssue is a bug

Type

No type

Projects

Status

Done

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @CaelmBleidd@alisevych@SBOne-Kenobi

    Issue actions

      Engine doesn't cover branch instanceof String · Issue #957 · UnitTestBot/UTBotJava