Closed
Description
Description
No test is generated for the true branch of the condition with String.split(";\s")
To Reproduce
Steps to reproduce the behavior:
- IntelliJ IDEA with UTBot plugin installed
- Fuzzing is on, slider is in default position
- Add the following Java class:
public class StringCharAt {
public boolean isSplitted(String s) {
if (s.split(";\\s").length > 1) {
return true;
}
return false;
}
}
- Use plugin to generate tests
- Open the generated test
Expected behavior
Tests are supposed to be generated for all code branches.
Actual behavior
There is only one successful test - with empty String, which is for the false branch.
Visual proofs (screenshots, logs, images)
The following test class is generated:
public class StringCharAtTest {
///region Test suites for executable StringCharAt.isSplitted
///region FUZZER: SUCCESSFUL EXECUTIONS for method isSplitted(java.lang.String)
@Test
@DisplayName("isSplitted: s = empty string -> return false")
public void testIsSplittedReturnsFalseWithEmptyString() {
StringCharAt stringCharAt = new StringCharAt();
boolean actual = stringCharAt.isSplitted("");
assertFalse(actual);
}
///endregion
///region SYMBOLIC EXECUTION ENGINE: ERROR SUITE for method isSplitted(java.lang.String)
/**
* <pre>
* Test invokes:
* {@link String#split(String)} once
*
* throws NullPointerException in: s.split("<\\s").length > 1
* </pre>
*/
@Test
@DisplayName("isSplitted: s.split(\"<\\\\s\").length > 1 -> ThrowNullPointerException")
public void testIsSplitted_StringSplit() {
StringCharAt stringCharAt = new StringCharAt();
/* This test fails because method [StringCharAt.isSplitted] produces [java.lang.NullPointerException]
StringCharAt.isSplitted(StringCharAt.java:11) */
stringCharAt.isSplitted(null);
}
///endregion
///endregion
}
Environment
Windows 10 Pro
JDK 11
Additional context
The same number of tests is generated for the following regex used : "<\s", ";\s"
If only "\s" or ";" is used - all branches are covered.
Metadata
Metadata
Assignees
Labels
Type
Projects
Status
Done