Skip to content

Avoid false positive Spring tests generated with Fuzzer #2228

@EgorkaKulikov

Description

@EgorkaKulikov

Description

Spring unit tests generated with symbolic engine avoid branches whis thisInstance == null if being null is actually impossible.
For example, because variable with @InjectMocks annotation is never null.

Fuzzer currently does not support this restrictions, so we generate tests like this:

///region FUZZER: ERROR SUITE for method useAbs(int)

@Test
@DisplayName("useAbs: x = -3 (mutated from -1) -> throw NullPointerException")
public void testUseAbsThrowsNPE() {
    /* This test fails because method [org.springframework.samples.math.MathUser.useAbs] produces [java.lang.NullPointerException]
        org.springframework.samples.math.MathUser.useAbs(MathUser.java:10) */
  mathUser.useAbs(-3);
}
///endregion

This test passes and writes that should fail :)

Metadata

Metadata

Assignees

Labels

comp-fuzzingIssue is related to the fuzzingcomp-springIssue is related to Spring projects supportctg-bugIssue is a bug

Type

No type

Projects

Status

Done

Relationships

None yet

Development

No branches or pull requests

Issue actions