Skip to content

Commit 0ff62da

Browse files
onewhlAbdullinAM
authored andcommitted
Include information about triggered recursion to Javadocs (UnitTestBot#1084)
Include information about triggered recursion to javadocs
1 parent 77194a3 commit 0ff62da

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

utbot-summary-tests/src/test/kotlin/examples/recursion/SummaryRecursionTest.kt

+4
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,9 @@ class SummaryRecursionTest : SummaryTestCaseGeneratorTest(
2626
val summary3 = "@utbot.classUnderTest {@link Recursion}\n" +
2727
"@utbot.methodUnderTest {@link org.utbot.examples.recursion.Recursion#fib(int)}\n" +
2828
"@utbot.executesCondition {@code (n == 1): False}\n" +
29+
"@utbot.triggersRecursion fib, where the test execute conditions:\n" +
30+
" {@code (n == 1): True}\n" +
31+
"return from: {@code return 1;}" +
2932
"@utbot.returnsFrom {@code return fib(n - 1) + fib(n - 2);}"
3033
val summary4 = "@utbot.classUnderTest {@link Recursion}\n" +
3134
"@utbot.methodUnderTest {@link org.utbot.examples.recursion.Recursion#fib(int)}\n" +
@@ -81,6 +84,7 @@ class SummaryRecursionTest : SummaryTestCaseGeneratorTest(
8184
val summary2 = "@utbot.classUnderTest {@link Recursion}\n" +
8285
"@utbot.methodUnderTest {@link org.utbot.examples.recursion.Recursion#factorial(int)}\n" +
8386
"@utbot.executesCondition {@code (n == 0): False}\n" +
87+
"@utbot.triggersRecursion factorial, where the test return from: {@code return 1;}" +
8488
"@utbot.returnsFrom {@code return n * factorial(n - 1);}"
8589
val summary3 = "@utbot.classUnderTest {@link Recursion}\n" +
8690
"@utbot.methodUnderTest {@link org.utbot.examples.recursion.Recursion#factorial(int)}\n" +

utbot-summary/src/main/kotlin/org/utbot/summary/comment/CustomJavaDocCommentBuilder.kt

+9-1
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ package org.utbot.summary.comment
33
import org.utbot.framework.plugin.api.DocCustomTagStatement
44
import org.utbot.framework.plugin.api.DocStatement
55
import org.utbot.framework.plugin.api.exceptionOrNull
6-
import org.utbot.summary.SummarySentenceConstants
76
import org.utbot.summary.SummarySentenceConstants.CARRIAGE_RETURN
87
import org.utbot.summary.ast.JimpleToASTMap
98
import org.utbot.summary.tag.TraceTagWithoutExecution
@@ -54,6 +53,15 @@ class CustomJavaDocCommentBuilder(
5453
comment.throwsException = "{@link $exceptionName} $reason".replace(CARRIAGE_RETURN, "")
5554
}
5655

56+
if (rootSentenceBlock.recursion != null) {
57+
comment.recursion += rootSentenceBlock.recursion?.first
58+
val insideRecursionSentence = rootSentenceBlock.recursion?.second?.toSentence()
59+
if (!insideRecursionSentence.isNullOrEmpty()) {
60+
comment.recursion += stringTemplates.insideRecursionSentence.format(insideRecursionSentence)
61+
.replace(CARRIAGE_RETURN, "").trim()
62+
}
63+
}
64+
5765
generateSequence(rootSentenceBlock) { it.nextBlock }.forEach {
5866
it.stmtTexts.forEach { statement ->
5967
processStatement(statement, comment)

0 commit comments

Comments
 (0)