Skip to content

Commit 207f353

Browse files
committed
Used coverage calculation instead of matchers for flaky executions number in some Set tests
1 parent e4607e6 commit 207f353

File tree

2 files changed

+13
-17
lines changed

2 files changed

+13
-17
lines changed

utbot-framework-test/src/test/kotlin/org/utbot/examples/collections/SetIteratorsTest.kt

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ class SetIteratorsTest : UtValueTestCaseChecker(
2222
fun testIteratorHasNext() {
2323
check(
2424
SetIterators::iteratorHasNext,
25-
between(3..4),
25+
ignoreExecutionsNumber,
2626
{ set, _ -> set == null },
2727
{ set, result -> set.isEmpty() && result == 0 },
2828
{ set, result -> set.isNotEmpty() && result == set.size },
@@ -33,7 +33,7 @@ class SetIteratorsTest : UtValueTestCaseChecker(
3333
fun testIteratorNext() {
3434
checkWithException(
3535
SetIterators::iteratorNext,
36-
between(3..4),
36+
ignoreExecutionsNumber,
3737
{ set, result -> set == null && result.isException<NullPointerException>() },
3838
{ set, result -> set != null && set.isEmpty() && result.isException<NoSuchElementException>() },
3939
// test should work as long as default class for set is LinkedHashSet
@@ -45,7 +45,7 @@ class SetIteratorsTest : UtValueTestCaseChecker(
4545
fun testIteratorRemove() {
4646
checkWithException(
4747
SetIterators::iteratorRemove,
48-
between(3..4),
48+
ignoreExecutionsNumber,
4949
{ set, result -> set == null && result.isException<NullPointerException>() },
5050
{ set, result -> set.isEmpty() && result.isException<NoSuchElementException>() },
5151
// test should work as long as default class for set is LinkedHashSet
@@ -62,7 +62,7 @@ class SetIteratorsTest : UtValueTestCaseChecker(
6262
fun testIteratorRemoveOnIndex() {
6363
checkWithException(
6464
SetIterators::iteratorRemoveOnIndex,
65-
ge(5),
65+
ignoreExecutionsNumber,
6666
{ _, i, result -> i == 0 && result.isSuccess && result.getOrNull() == null },
6767
{ set, _, result -> set == null && result.isException<NullPointerException>() },
6868
{ set, i, result -> set != null && i < 0 && result.isException<IllegalStateException>() },

utbot-framework-test/src/test/kotlin/org/utbot/examples/collections/SetsTest.kt

Lines changed: 9 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,11 @@ package org.utbot.examples.collections
22

33
import org.utbot.tests.infrastructure.UtValueTestCaseChecker
44
import org.utbot.tests.infrastructure.AtLeast
5-
import org.utbot.tests.infrastructure.DoNotCalculate
6-
import org.utbot.tests.infrastructure.between
75
import org.utbot.tests.infrastructure.ignoreExecutionsNumber
86
import org.utbot.framework.plugin.api.CodegenLanguage
97
import org.junit.jupiter.api.Disabled
108
import org.junit.jupiter.api.Test
119
import org.utbot.testcheckers.eq
12-
import org.utbot.testcheckers.ge
1310
import org.utbot.testcheckers.withPushingStateFromPathSelectorForConcrete
1411
import org.utbot.testcheckers.withoutMinimization
1512
import org.utbot.tests.infrastructure.CodeGeneration
@@ -30,7 +27,7 @@ internal class SetsTest : UtValueTestCaseChecker(
3027
eq(3),
3128
{ a, _ -> a == null },
3229
{ a, r -> a != null && a.isEmpty() && r!!.isEmpty() },
33-
{ a, r -> a != null && a.isNotEmpty() && r != null && r.isNotEmpty() && r.containsAll(a.toList()) },
30+
{ a, r -> a != null && a.isNotEmpty() && !r.isNullOrEmpty() && r.containsAll(a.toList()) },
3431
)
3532
}
3633

@@ -92,7 +89,7 @@ internal class SetsTest : UtValueTestCaseChecker(
9289
val resultFun = { set: Set<Char> -> listOf(' ', '\t', '\r', '\n').intersect(set).size }
9390
check(
9491
Sets::removeSpace,
95-
ge(3),
92+
ignoreExecutionsNumber,
9693
{ set, _ -> set == null },
9794
{ set, res -> ' ' in set && resultFun(set) == res },
9895
{ set, res -> '\t' in set && resultFun(set) == res },
@@ -109,7 +106,7 @@ internal class SetsTest : UtValueTestCaseChecker(
109106
fun addElementsTest() {
110107
check(
111108
Sets::addElements,
112-
ge(5),
109+
ignoreExecutionsNumber,
113110
{ set, _, _ -> set == null },
114111
{ set, a, _ -> set != null && set.isNotEmpty() && a == null },
115112
{ set, _, r -> set.isEmpty() && r == set },
@@ -124,7 +121,7 @@ internal class SetsTest : UtValueTestCaseChecker(
124121
fun removeElementsTest() {
125122
check(
126123
Sets::removeElements,
127-
between(6..8),
124+
ignoreExecutionsNumber,
128125
{ set, _, _, _ -> set == null },
129126
{ set, i, j, res -> set != null && i !in set && j !in set && res == -1 },
130127
{ set, i, j, res -> set != null && set.size >= 1 && i !in set && j in set && res == 4 },
@@ -150,7 +147,7 @@ internal class SetsTest : UtValueTestCaseChecker(
150147
withoutMinimization { // TODO: JIRA:1506
151148
check(
152149
Sets::removeCustomObject,
153-
ge(4),
150+
ignoreExecutionsNumber,
154151
{ set, _, _ -> set == null },
155152
{ set, _, result -> set.isEmpty() && result == 0 },
156153
{ set, i, result -> set.isNotEmpty() && CustomClass(i) !in set && result == 0 },
@@ -188,7 +185,6 @@ internal class SetsTest : UtValueTestCaseChecker(
188185
//TODO: JIRA:1666 -- Engine ignores branches in Wrappers sometimes
189186
// TODO: cannot find branch with result == 2
190187
// { set, other, result -> !set.containsAll(other) && other.any { it in set } && result == 2 },
191-
coverage = DoNotCalculate
192188
)
193189
}
194190
}
@@ -197,7 +193,7 @@ internal class SetsTest : UtValueTestCaseChecker(
197193
fun testRetainAllElements() {
198194
check(
199195
Sets::retainAllElements,
200-
ge(4),
196+
ignoreExecutionsNumber,
201197
{ set, _, _ -> set == null },
202198
{ set, other, _ -> set != null && other == null },
203199
{ set, other, result -> other.containsAll(set) && result == 1 },
@@ -209,7 +205,7 @@ internal class SetsTest : UtValueTestCaseChecker(
209205
fun testContainsAllElements() {
210206
check(
211207
Sets::containsAllElements,
212-
ge(5),
208+
ignoreExecutionsNumber,
213209
{ set, _, _ -> set == null },
214210
{ set, other, _ -> set != null && other == null },
215211
{ set, other, result -> set.isEmpty() || other.isEmpty() && result == -1 },
@@ -223,7 +219,7 @@ internal class SetsTest : UtValueTestCaseChecker(
223219
fun testClearElements() {
224220
check(
225221
Sets::clearElements,
226-
eq(3),
222+
ignoreExecutionsNumber,
227223
{ set, _ -> set == null },
228224
{ set, result -> set.isEmpty() && result == 0 },
229225
{ set, result -> set.isNotEmpty() && result == 1 },
@@ -236,7 +232,7 @@ internal class SetsTest : UtValueTestCaseChecker(
236232
fun testContainsElement() {
237233
check(
238234
Sets::containsElement,
239-
between(3..5),
235+
ignoreExecutionsNumber,
240236
{ set, _, _ -> set == null },
241237
{ set, i, result -> i !in set && result == 0 },
242238
{ set, i, result -> i in set && result == 1 },

0 commit comments

Comments
 (0)