Skip to content

Commit 2664bd4

Browse files
sofurihafetamarinvs19
authored andcommitted
Move all summary tests in utbot-summary-tests project (#1765)
* Remove duplicate summary tests from engine checks * Move summary tests from engine checks to separate summary tests * Remove summary checks from engine checks
1 parent 5a89c4d commit 2664bd4

File tree

17 files changed

+512
-1641
lines changed

17 files changed

+512
-1641
lines changed

utbot-framework-api/src/main/kotlin/org/utbot/framework/UtSettings.kt

Lines changed: 0 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -116,21 +116,6 @@ object UtSettings : AbstractSettings(logger, defaultKeyForSettingsPath, defaultS
116116
*/
117117
var useExpressionSimplification by getBooleanProperty(true)
118118

119-
/**
120-
* Activate or deactivate tests on comments
121-
*/
122-
var testSummary by getBooleanProperty(true)
123-
124-
/**
125-
* Activate or deactivate tests on names
126-
*/
127-
var testName by getBooleanProperty(true)
128-
129-
/**
130-
* Activate or deactivate tests on displayNames
131-
*/
132-
var testDisplayName by getBooleanProperty(true)
133-
134119
/**
135120
* Enable the Summarization module to generate summaries for methods under test.
136121
*

utbot-framework-test/src/test/kotlin/org/utbot/examples/algorithms/BinarySearchTest.kt

Lines changed: 1 addition & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,5 @@
11
package org.utbot.examples.algorithms
22

3-
import org.utbot.framework.plugin.api.DocCodeStmt
4-
import org.utbot.framework.plugin.api.DocPreTagStatement
5-
import org.utbot.framework.plugin.api.DocRegularStmt
6-
import org.utbot.framework.plugin.api.DocStatement
73
import org.junit.jupiter.api.Test
84
import org.utbot.testing.UtValueTestCaseChecker
95
import org.utbot.testing.ignoreExecutionsNumber
@@ -12,60 +8,14 @@ import org.utbot.testing.isException
128
class BinarySearchTest : UtValueTestCaseChecker(testClass = BinarySearch::class,) {
139
@Test
1410
fun testLeftBinarySearch() {
15-
val fullSummary = listOf<DocStatement>(
16-
DocPreTagStatement(
17-
listOf(
18-
DocRegularStmt("Test "),
19-
DocRegularStmt("does not iterate "),
20-
DocCodeStmt("while(left < right - 1)"),
21-
DocRegularStmt(", "),
22-
DocRegularStmt("executes conditions:\n"),
23-
DocRegularStmt(" "),
24-
DocCodeStmt("(found): False"),
25-
DocRegularStmt("\n"),
26-
DocRegularStmt("returns from: "),
27-
DocCodeStmt("return -1;"),
28-
DocRegularStmt("\n")
29-
30-
)
31-
)
32-
)
3311
checkWithException(
3412
BinarySearch::leftBinSearch,
3513
ignoreExecutionsNumber,
3614
{ a, _, r -> a == null && r.isException<NullPointerException>() },
3715
{ a, _, r -> a.size >= 2 && a[0] > a[1] && r.isException<IllegalArgumentException>() },
3816
{ a, _, r -> a.isEmpty() && r.getOrNull() == -1 },
3917
{ a, key, r -> a.isNotEmpty() && key >= a[(a.size - 1) / 2] && key !in a && r.getOrNull() == -1 },
40-
{ a, key, r -> a.isNotEmpty() && key in a && r.getOrNull() == a.indexOfFirst { it == key } + 1 },
41-
// TODO enable it JIRA:1442
42-
/*
43-
summaryTextChecks = listOf(
44-
keyContain(DocCodeStmt("(found): False")),
45-
keyContain(DocCodeStmt("(found): True")),
46-
keyContain(DocRegularStmt(" BinarySearch::isUnsorted once")),
47-
keyContain(DocRegularStmt("throws NullPointerException in: isUnsorted(array)")),
48-
keyContain(DocRegularStmt("throws IllegalArgumentException after condition: isUnsorted(array)")),
49-
keyContain(DocCodeStmt("(array[middle] < key): True")),
50-
keyContain(DocCodeStmt("(array[middle] == key): True")),
51-
keyContain(DocCodeStmt("(array[middle] < key): True")),
52-
keyMatch(fullSummary)
53-
),
54-
summaryNameChecks = listOf(
55-
keyContain("testLeftBinSearch_BinarySearchIsUnsorted"),
56-
keyContain("testLeftBinSearch_ThrowIllegalArgumentException"),
57-
keyContain("testLeftBinSearch_NotFound"),
58-
keyContain("testLeftBinSearch_MiddleOfArrayLessThanKey"),
59-
keyContain("testLeftBinSearch_Found")
60-
),
61-
summaryDisplayNameChecks = listOf(
62-
keyMatch("isUnsorted(array) -> ThrowIllegalArgumentException"),
63-
keyMatch("isUnsorted(array) -> ThrowIllegalArgumentException"),
64-
keyMatch("found : False -> return -1"),
65-
keyMatch("array[middle] == key : True -> return right + 1"),
66-
keyMatch("array[middle] < key : True -> return -1")
67-
)
68-
*/
18+
{ a, key, r -> a.isNotEmpty() && key in a && r.getOrNull() == a.indexOfFirst { it == key } + 1 }
6919
)
7020
}
7121

utbot-framework-test/src/test/kotlin/org/utbot/examples/algorithms/CorrectBracketSequencesTest.kt

Lines changed: 3 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,6 @@
11
package org.utbot.examples.algorithms
22

33
import org.utbot.framework.plugin.api.CodegenLanguage
4-
import org.utbot.framework.plugin.api.DocCodeStmt
5-
import org.utbot.framework.plugin.api.DocPreTagStatement
6-
import org.utbot.framework.plugin.api.DocRegularStmt
74
import org.junit.jupiter.api.Test
85
import org.utbot.examples.algorithms.CorrectBracketSequences.isBracket
96
import org.utbot.examples.algorithms.CorrectBracketSequences.isOpen
@@ -12,7 +9,6 @@ import org.utbot.testing.CodeGeneration
129
import org.utbot.testing.UtValueTestCaseChecker
1310
import org.utbot.testing.ignoreExecutionsNumber
1411
import org.utbot.testing.isException
15-
import org.utbot.testing.keyMatch
1612

1713
internal class CorrectBracketSequencesTest : UtValueTestCaseChecker(
1814
testClass = CorrectBracketSequences::class,
@@ -24,50 +20,18 @@ internal class CorrectBracketSequencesTest : UtValueTestCaseChecker(
2420
) {
2521
@Test
2622
fun testIsOpen() {
27-
val isOpenSummary = listOf(
28-
DocPreTagStatement(
29-
listOf(
30-
DocRegularStmt("Test "),
31-
DocRegularStmt("returns from: "),
32-
DocCodeStmt("return a == '(' || a == '{' || a == '[';"),
33-
DocRegularStmt("\n")
34-
)
35-
)
36-
)
37-
3823
checkStaticMethod(
3924
CorrectBracketSequences::isOpen,
4025
eq(4),
4126
{ c, r -> c == '(' && r == true },
4227
{ c, r -> c == '{' && r == true },
4328
{ c, r -> c == '[' && r == true },
44-
{ c, r -> c !in "({[".toList() && r == false },
45-
summaryNameChecks = listOf(
46-
keyMatch("testIsOpen_AEqualsCharOrAEqualsCharOrAEqualsChar"),
47-
keyMatch("testIsOpen_ANotEqualsCharOrANotEqualsCharOrANotEqualsChar")
48-
),
49-
summaryDisplayNameChecks = listOf(
50-
keyMatch("return a == '(' || a == '{' || a == '[' : False -> return a == '(' || a == '{' || a == '['"),
51-
keyMatch("return a == '(' || a == '{' || a == '[' : True -> return a == '(' || a == '{' || a == '['")
52-
),
53-
summaryTextChecks = listOf(
54-
keyMatch(isOpenSummary)
55-
)
29+
{ c, r -> c !in "({[".toList() && r == false }
5630
)
5731
}
5832

5933
@Test
6034
fun testIsBracket() {
61-
val isBracketSummary = listOf(
62-
DocPreTagStatement(
63-
listOf(
64-
DocRegularStmt("Test "),
65-
DocRegularStmt("returns from: "),
66-
DocCodeStmt("return isOpen(a) || a == ')' || a == '}' || a == ']';"),
67-
DocRegularStmt("\n")
68-
)
69-
)
70-
)
7135
checkStaticMethod(
7236
CorrectBracketSequences::isBracket,
7337
eq(7),
@@ -77,33 +41,12 @@ internal class CorrectBracketSequencesTest : UtValueTestCaseChecker(
7741
{ c, r -> c == ')' && r == true },
7842
{ c, r -> c == '}' && r == true },
7943
{ c, r -> c == ']' && r == true },
80-
{ c, r -> c !in "(){}[]".toList() && r == false },
81-
summaryNameChecks = listOf(
82-
keyMatch("testIsBracket_IsOpenOrANotEqualsCharOrANotEqualsCharOrANotEqualsChar"),
83-
keyMatch("testIsBracket_IsOpenOrAEqualsCharOrAEqualsCharOrAEqualsChar")
84-
),
85-
summaryDisplayNameChecks = listOf(
86-
keyMatch("return isOpen(a) || a == ')' || a == '}' || a == ']' : False -> return isOpen(a) || a == ')' || a == '}' || a == ']'"),
87-
keyMatch("return isOpen(a) || a == ')' || a == '}' || a == ']' : True -> return isOpen(a) || a == ')' || a == '}' || a == ']'")
88-
),
89-
summaryTextChecks = listOf(
90-
keyMatch(isBracketSummary)
91-
)
44+
{ c, r -> c !in "(){}[]".toList() && r == false }
9245
)
9346
}
9447

9548
@Test
9649
fun testIsTheSameType() {
97-
val isTheSameTypeSummary = listOf(
98-
DocPreTagStatement(
99-
listOf(
100-
DocRegularStmt("Test "),
101-
DocRegularStmt("returns from: "),
102-
DocCodeStmt("return a == '(' && b == ')' || a == '{' && b == '}' || a == '[' && b == ']';"),
103-
DocRegularStmt("\n")
104-
)
105-
)
106-
)
10750
checkStaticMethod(
10851
CorrectBracketSequences::isTheSameType,
10952
ignoreExecutionsNumber,
@@ -113,18 +56,7 @@ internal class CorrectBracketSequencesTest : UtValueTestCaseChecker(
11356
{ a, b, r -> a == '(' && b != ')' && r == false },
11457
{ a, b, r -> a == '{' && b != '}' && r == false },
11558
{ a, b, r -> a == '[' && b != ']' && r == false },
116-
{ a, b, r -> (a != '(' || b != ')') && (a != '{' || b != '}') && (a != '[' || b != ']') && r == false },
117-
summaryNameChecks = listOf(
118-
keyMatch("testIsTheSameType_ANotEqualsCharAndBNotEqualsCharOrANotEqualsCharAndBNotEqualsCharOrANotEqualsCharAndBNotEqualsChar"),
119-
keyMatch("testIsTheSameType_AEqualsCharAndBEqualsCharOrAEqualsCharAndBEqualsCharOrAEqualsCharAndBEqualsChar"),
120-
),
121-
summaryDisplayNameChecks = listOf(
122-
keyMatch("return a == '(' && b == ')' || a == '{' && b == '}' || a == '[' && b == ']' : False -> return a == '(' && b == ')' || a == '{' && b == '}' || a == '[' && b == ']'"),
123-
keyMatch("return a == '(' && b == ')' || a == '{' && b == '}' || a == '[' && b == ']' : True -> return a == '(' && b == ')' || a == '{' && b == '}' || a == '[' && b == ']'")
124-
),
125-
summaryTextChecks = listOf(
126-
keyMatch(isTheSameTypeSummary)
127-
)
59+
{ a, b, r -> (a != '(' || b != ')') && (a != '{' || b != '}') && (a != '[' || b != ']') && r == false }
12860
)
12961
}
13062

utbot-framework-test/src/test/kotlin/org/utbot/examples/algorithms/SortTest.kt

Lines changed: 2 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,5 @@
11
package org.utbot.examples.algorithms
22

3-
import org.utbot.framework.plugin.api.DocCodeStmt
4-
import org.utbot.framework.plugin.api.DocPreTagStatement
5-
import org.utbot.framework.plugin.api.DocRegularStmt
63
import org.utbot.framework.plugin.api.MockStrategyApi
74
import org.junit.jupiter.api.Test
85
import org.utbot.framework.plugin.api.CodegenLanguage
@@ -12,7 +9,6 @@ import org.utbot.testing.CodeGeneration
129
import org.utbot.testing.UtValueTestCaseChecker
1310
import org.utbot.testing.ignoreExecutionsNumber
1411
import org.utbot.testing.isException
15-
import org.utbot.testing.keyMatch
1612

1713
// TODO Kotlin mocks generics https://github.com/UnitTestBot/UTBotJava/issues/88
1814
internal class SortTest : UtValueTestCaseChecker(
@@ -111,54 +107,12 @@ internal class SortTest : UtValueTestCaseChecker(
111107
val connection = lhs.last() >= rhs.last() && r.getOrNull()?.toList() == (lhs + rhs).sorted()
112108

113109
lhsCondition && rhsCondition && connection
114-
},
110+
}
115111
)
116112
}
117113

118114
@Test
119115
fun testDefaultSort() {
120-
val defaultSortSummary1 = listOf(
121-
DocPreTagStatement(
122-
listOf(
123-
DocRegularStmt("Test "),
124-
DocRegularStmt("\n"),
125-
DocRegularStmt("throws NullPointerException in: array.length < 4"),
126-
DocRegularStmt("\n")
127-
)
128-
)
129-
)
130-
131-
val defaultSortSummary2 = listOf(
132-
DocPreTagStatement(
133-
listOf(
134-
DocRegularStmt("Test "),
135-
DocRegularStmt("executes conditions:\n"),
136-
DocRegularStmt(" "),
137-
DocCodeStmt("(array.length < 4): True"),
138-
DocRegularStmt("\n"),
139-
DocRegularStmt("\n"),
140-
DocRegularStmt("throws IllegalArgumentException after condition: array.length < 4"),
141-
DocRegularStmt("\n")
142-
)
143-
)
144-
)
145-
val defaultSortSummary3 = listOf(
146-
DocPreTagStatement(
147-
listOf(
148-
DocRegularStmt("Test "),
149-
DocRegularStmt("executes conditions:\n"),
150-
DocRegularStmt(" "),
151-
DocCodeStmt("(array.length < 4): False"),
152-
DocRegularStmt("\n"),
153-
DocRegularStmt("invokes:\n"),
154-
DocRegularStmt(" {@link java.util.Arrays#sort(int[])} once"),
155-
DocRegularStmt("\n"),
156-
DocRegularStmt("returns from: "),
157-
DocCodeStmt("return array;"),
158-
DocRegularStmt("\n")
159-
)
160-
)
161-
)
162116
checkWithException(
163117
Sort::defaultSort,
164118
eq(3),
@@ -167,22 +121,7 @@ internal class SortTest : UtValueTestCaseChecker(
167121
{ a, r ->
168122
val resultArray = intArrayOf(-100, 0, 100, 200)
169123
a != null && r.getOrNull()!!.size >= 4 && r.getOrNull() contentEquals resultArray
170-
},
171-
summaryTextChecks = listOf(
172-
keyMatch(defaultSortSummary1),
173-
keyMatch(defaultSortSummary2),
174-
keyMatch(defaultSortSummary3),
175-
),
176-
summaryNameChecks = listOf(
177-
keyMatch("testDefaultSort_ThrowNullPointerException"),
178-
keyMatch("testDefaultSort_ArrayLengthLessThan4"),
179-
keyMatch("testDefaultSort_ArrayLengthGreaterOrEqual4"),
180-
),
181-
summaryDisplayNameChecks = listOf(
182-
keyMatch("array.length < 4 -> ThrowNullPointerException"),
183-
keyMatch("array.length < 4 -> ThrowIllegalArgumentException"),
184-
keyMatch("array.length < 4 : False -> return array"),
185-
)
124+
}
186125
)
187126
}
188127
}

utbot-framework-test/src/test/kotlin/org/utbot/examples/controlflow/ConditionsTest.kt

Lines changed: 1 addition & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,18 @@
11
package org.utbot.examples.controlflow
22

3-
import org.utbot.framework.plugin.api.DocCodeStmt
4-
import org.utbot.framework.plugin.api.DocPreTagStatement
5-
import org.utbot.framework.plugin.api.DocRegularStmt
6-
import org.utbot.framework.plugin.api.DocStatement
73
import org.junit.jupiter.api.Test
84
import org.utbot.testcheckers.eq
95
import org.utbot.testing.UtValueTestCaseChecker
106
import org.utbot.testing.ignoreExecutionsNumber
11-
import org.utbot.testing.keyContain
12-
import org.utbot.testing.keyMatch
137

148
internal class ConditionsTest : UtValueTestCaseChecker(testClass = Conditions::class) {
159
@Test
1610
fun testSimpleCondition() {
17-
val conditionSummary = listOf<DocStatement>(
18-
DocPreTagStatement(
19-
listOf(
20-
DocRegularStmt("Test "),
21-
DocRegularStmt("executes conditions:\n"),
22-
DocRegularStmt(" "),
23-
DocCodeStmt("(condition): True"),
24-
DocRegularStmt("\n"),
25-
DocRegularStmt("returns from: "),
26-
DocCodeStmt("return 1;"),
27-
DocRegularStmt("\n"),
28-
)
29-
)
30-
)
3111
check(
3212
Conditions::simpleCondition,
3313
eq(2),
3414
{ condition, r -> !condition && r == 0 },
35-
{ condition, r -> condition && r == 1 },
36-
summaryTextChecks = listOf(
37-
keyContain(DocCodeStmt("(condition): True")),
38-
keyContain(DocCodeStmt("(condition): False")),
39-
keyMatch(conditionSummary)
40-
),
41-
summaryNameChecks = listOf(
42-
keyMatch("testSimpleCondition_Condition"),
43-
keyMatch("testSimpleCondition_NotCondition"),
44-
),
45-
summaryDisplayNameChecks = listOf(
46-
keyContain("condition : True"),
47-
keyContain("condition : False"),
48-
)
15+
{ condition, r -> condition && r == 1 }
4916
)
5017
}
5118

0 commit comments

Comments
 (0)