-
Notifications
You must be signed in to change notification settings - Fork 45
Open
Assignees
@alisevych
Description
Description
There are no meaningful tests generated for methods containing String methods calls in Kotlin.
Verified:
- trimMargin (String)
- matches (Regex)
To Reproduce
- Install one of the latest builds of UnitTestBot plugin from main into IntelliJ Idea 2022年1月4日
- Create a project with Kotlin support
- Use plugin to generate tests for the following Kotlin class:
public class StringTemplates { val month = "(JAN|FEB|MAR|APR|MAY|JUN|JUL|AUG|SEP|OCT|NOV|DEC)" fun getPattern(): String = """\d{2} $month \d{4}""" fun matchString(string: String) : Boolean { return string.matches( getPattern().toRegex()) } }
Expected behavior
At very least tests that do and do not match pattern are expected.
Also it would be great to generate some other "corner" cases:
- one digit at the beginning
- with
JAN|FEB
as the month - with misprint
JA
as the month - with
99
or00
as the day - etc.
Actual behavior
Generated Kotlin test contains two identical tests.
Visual proofs (screenshots, logs, images)
The following test class is generated:
public class StringTemplatesTest { ///region Test suites for executable koans.StringTemplates.matchString ///region /** * @utbot.classUnderTest {@link StringTemplates} * @utbot.methodUnderTest {@link StringTemplates#matchString(String)} */ @Test @DisplayName("matchString: string = empty string -> return false") public void testMatchStringReturnsFalseWithEmptyString() { StringTemplates stringTemplates = new StringTemplates(); boolean actual = stringTemplates.matchString(""); assertFalse(actual); } ///endregion ///region FUZZER: SUCCESSFUL EXECUTIONS for method matchString(java.lang.String) /** * @utbot.classUnderTest {@link StringTemplates} * @utbot.methodUnderTest {@link StringTemplates#matchString(String)} */ @Test @DisplayName("matchString: matchString: string = empty string -> return false") public void testMatchStringReturnsFalseWithEmptyString1() { StringTemplates stringTemplates = new StringTemplates(); boolean actual = stringTemplates.matchString(""); assertFalse(actual); } ///endregion ///endregion }
Environment
Windows 10 Pro
IDEA 2022年1月4日
Metadata
Metadata
Assignees
Type
Projects
Status
Todo