-
Notifications
You must be signed in to change notification settings - Fork 45
Description
Description
String
class has two overloaded methods to split the string around matches of the given regular expressions:
String[] split(String regex)
String[] split(String regex, int limit)
These methods are implemented in UtString
via concrete execution. It prevents the symbolic engine to trace possible paths in these methods.
To Reproduce
Create a method with a call to String.split
and generate a test suite for this method:
public class SplitExample {
public boolean hasManyWords(@NotNull String str) {
String[] components = str.split(" ");
return components.length >= 3;
}
}
Expected behavior
A test suite with two tests, one for each possible return value of hasManyWords
(true
and false
).
Actual behavior
A test suite with only one test corresponding to false
as the return value.
Visual proofs
///region SUCCESSFUL EXECUTIONS for method hasManyWords(java.lang.String)
/**
*
*/
@Test
@DisplayName("hasManyWords: ")
public void testHasManyWords() throws Throwable {
MissingMethods missingMethods = new MissingMethods();
String string = "";
boolean actual = missingMethods.hasManyWords(string);
assertFalse(actual);
}
///endregion
Environment
Test framework: JUnit5 (the issue does not depend on the test framework).
Java: 8 (Corretto 1.8.0_332
)
Mockito: any settings produce the same behavior.
Test: not parameterized
Metadata
Metadata
Assignees
Labels
Type
Projects
Status