-
Notifications
You must be signed in to change notification settings - Fork 45
Handle RecursionAssignment, SwitchCase, and CaughtException statement types in CustomJavaDocCommentBuilder #888
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from 1 commit
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add tests for recursion tag
- Loading branch information
commit a71bfa32fb690775ed97bf98db7eb8bfd2d9978d
There are no files selected for viewing
123 changes: 123 additions & 0 deletions
123
utbot-summary-tests/src/test/kotlin/examples/recursion/SummaryRecursionTest.kt
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,123 @@ | ||
| package examples.recursion | ||
|
|
||
| import examples.CustomJavaDocTagsEnabler | ||
| import examples.SummaryTestCaseGeneratorTest | ||
| import org.junit.jupiter.api.Test | ||
| import org.junit.jupiter.api.extension.ExtendWith | ||
| import org.utbot.examples.recursion.Recursion | ||
| import org.utbot.framework.plugin.api.MockStrategyApi | ||
| import org.utbot.tests.infrastructure.DoNotCalculate | ||
|
|
||
| @ExtendWith(CustomJavaDocTagsEnabler::class) | ||
| class SummaryRecursionTest : SummaryTestCaseGeneratorTest( | ||
| Recursion::class | ||
| ) { | ||
| @Test | ||
| fun testFib() { | ||
| val summary1 = "@utbot.classUnderTest {@link Recursion}\n" + | ||
| "@utbot.methodUnderTest {@link org.utbot.examples.recursion.Recursion#fib(int)}\n" + | ||
| "@utbot.executesCondition {@code (n == 0): False},\n" + | ||
| "{@code (n == 1): True}\n" + | ||
| "@utbot.returnsFrom {@code return 1;}" | ||
| val summary2 = "@utbot.classUnderTest {@link Recursion}\n" + | ||
| "@utbot.methodUnderTest {@link org.utbot.examples.recursion.Recursion#fib(int)}\n" + | ||
| "@utbot.executesCondition {@code (n == 0): True}\n" + | ||
| "@utbot.returnsFrom {@code return 0;}\n" | ||
| val summary3 = "@utbot.classUnderTest {@link Recursion}\n" + | ||
| "@utbot.methodUnderTest {@link org.utbot.examples.recursion.Recursion#fib(int)}\n" + | ||
| "@utbot.executesCondition {@code (n == 1): False}\n" + | ||
| "@utbot.returnsFrom {@code return fib(n - 1) + fib(n - 2);}" | ||
| val summary4 = "@utbot.classUnderTest {@link Recursion}\n" + | ||
| "@utbot.methodUnderTest {@link org.utbot.examples.recursion.Recursion#fib(int)}\n" + | ||
| "@utbot.executesCondition {@code (n < 0): True}\n" + | ||
| "@utbot.throwsException {@link java.lang.IllegalArgumentException} in: n < 0" | ||
|
|
||
| val methodName1 = "testFib_Return1" | ||
| val methodName2 = "testFib_ReturnZero" | ||
| val methodName3 = "testFib_NNotEquals1" | ||
| val methodName4 = "testFib_NLessThanZero" | ||
|
|
||
| val displayName1 = "n == 0 : False -> return 1" | ||
| val displayName2 = "n == 0 : True -> return 0" | ||
| val displayName3 = "return 1 -> return 0" //it looks weird | ||
| val displayName4 = "n < 0 -> ThrowIllegalArgumentException" | ||
|
|
||
| val summaryKeys = listOf( | ||
| summary1, | ||
| summary2, | ||
| summary3, | ||
| summary4 | ||
| ) | ||
|
|
||
| val displayNames = listOf( | ||
| displayName1, | ||
| displayName2, | ||
| displayName3, | ||
| displayName4 | ||
| ) | ||
|
|
||
| val methodNames = listOf( | ||
| methodName1, | ||
| methodName2, | ||
| methodName3, | ||
| methodName4 | ||
| ) | ||
|
|
||
| val method = Recursion::fib | ||
| val mockStrategy = MockStrategyApi.NO_MOCKS | ||
| val coverage = DoNotCalculate | ||
|
|
||
| summaryCheck(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames) | ||
| } | ||
|
|
||
| @Test | ||
| fun testFactorial() { | ||
| val summary1 = "@utbot.classUnderTest {@link Recursion}\n" + | ||
| "@utbot.methodUnderTest {@link org.utbot.examples.recursion.Recursion#factorial(int)}\n" + | ||
| //TODO: this condition is lost in both SimpleCommentBuilder ans CustomJavaDocCommentBuilder | ||
|
onewhl marked this conversation as resolved.
Outdated
|
||
| //"@utbot.executesCondition {@code (n == 0): True}\n" | ||
| "@utbot.returnsFrom {@code return 1;}" | ||
| val summary2 = "@utbot.classUnderTest {@link Recursion}\n" + | ||
| "@utbot.methodUnderTest {@link org.utbot.examples.recursion.Recursion#factorial(int)}\n" + | ||
| "@utbot.executesCondition {@code (n == 0): False}\n" + | ||
| "@utbot.returnsFrom {@code return n * factorial(n - 1);}" | ||
| val summary3 = "@utbot.classUnderTest {@link Recursion}\n" + | ||
| "@utbot.methodUnderTest {@link org.utbot.examples.recursion.Recursion#factorial(int)}\n" + | ||
| "@utbot.executesCondition {@code (n < 0): True}\n" + | ||
| "@utbot.throwsException {@link java.lang.IllegalArgumentException} after condition: n < 0" | ||
|
|
||
| val methodName1 = "testFactorial_Return1" | ||
| val methodName2 = "testFactorial_NNotEqualsZero" | ||
| val methodName3 = "testFactorial_NLessThanZero" | ||
|
|
||
| //TODO: display names are not complete, | ||
| //they should be equal "n == 0 : True -> return 1" and "n == 0 : False -> return n * factorial(n - 1)" respectively | ||
|
onewhl marked this conversation as resolved.
|
||
| val displayName1 = "-> return 1" | ||
| val displayName2 = "-> return 1" | ||
| val displayName3 = "n < 0 -> ThrowIllegalArgumentException" | ||
|
|
||
| val summaryKeys = listOf( | ||
| summary1, | ||
| summary2, | ||
| summary3 | ||
| ) | ||
|
|
||
| val displayNames = listOf( | ||
| displayName1, | ||
| displayName2, | ||
| displayName3 | ||
| ) | ||
|
|
||
| val methodNames = listOf( | ||
| methodName1, | ||
| methodName2, | ||
| methodName3 | ||
| ) | ||
|
|
||
| val method = Recursion::factorial | ||
| val mockStrategy = MockStrategyApi.NO_MOCKS | ||
| val coverage = DoNotCalculate | ||
|
|
||
| summaryCheck(method, mockStrategy, coverage, summaryKeys, methodNames, displayNames) | ||
| } | ||
| } | ||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just thought that in future we could have something like testing dsl
javadoc {
methodUnderTest = "org.utbot.examples.recursion.Recursion#fib(int)"
executesCondition = "(n == 0): False"
}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yesss, it would be awesome!