Repository navigation
Summaries are not generated for methods from nested classes of nested classes #710
Description
Description
If we have a chain of at least three classes nested in each other (like class A { class B { class C { int f(); } } } ), summaries are not generated for the functions of the innermost of them (A.B.C.f() in our example).
To Reproduce
UPD. Nested classes are now supported in plugin, so the behavior can be reproduced just by launching plugin on the below class
As nested classes are currently supported only in contest estimator, the easiest way to reproduce the bug is through tests:
- Add file
DeepNested.javaintoutbot-sample/src/main/java/org/utbot/examples/inner/with the following content:
package org.utbot.examples.inner;
public class DeepNested {
public class Nested1 {
public class Nested2 {
public int f() {
return 0;
}
}
}
}- Add file
DeepNestedTest.ktintoutbot-summary-tests/src/test/kotlin/examples/inner/with the following content:
package examples.inner
import examples.SummaryTestCaseGeneratorTest
import org.junit.jupiter.api.Test
import org.utbot.examples.DoNotCalculate
import org.utbot.examples.inner.DeepNested
import org.utbot.framework.plugin.api.MockStrategyApi
class DeepNestedTest : SummaryTestCaseGeneratorTest(
DeepNested::class,
) {
@Test
fun testF() {
val summary1 = "Test returns from: return 0;"
val method = DeepNested.Nested1.Nested2::f
val mockStrategy = MockStrategyApi.NO_MOCKS
val coverage = DoNotCalculate
val summaryKeys = listOf(
summary1
)
summaryCheck(method, mockStrategy, coverage, summaryKeys)
}
}Expected behavior
Test passes, as corresponding summaries are generated for tests for A.B.C.f()
Actual behavior
Test fails because no summaries are generated.
Visual proofs (screenshots, logs, images)
Test fails with assertion message
The following comments were produced by the UTBot, but were not found in the list of comments passed in the check() method:
-------------------------------------------------------------
null-------------------------------------------------------------
The following comments were passed in the check() method, but were not found in the list of comments produced by the UTBot:
-------------------------------------------------------------
Test returns from: return 0;
-------------------------------------------------------------
Environment
Nothing specific.
Additional context
For me it seems that problem is in org.utbot.summary.ast.SourceCodeParser#traverseInnerClassDeclarations and the fact that it doesn't make any recursive calls.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
amandelpie commentedon Aug 17, 2022
@volivan239 could you please notify me, when nested class will be supported not only in the ContestEstimator
volivan239 commentedon Aug 17, 2022
@amandelpie, OK, that's no problem. Right now test generation for nested classes from plugin works in this branch. I will notify once it will be merged into main, but that's unlikely to happen soon because currently related people are on vacations.
volivan239 commentedon Aug 31, 2022
@amandelpie nested classes are now supported in plugin. The behavior can be reproduced just by copy-pasting
DeepNestedclass from example to any project and launching plugin on it.