Skip to content

Commit c371759

Browse files
committed
Review Feedback Vol. 1
1 parent dc592b5 commit c371759

1 file changed

Lines changed: 30 additions & 28 deletions

File tree

spock-specs/src/test/groovy/spock/util/concurrent/PollingConditionsSpec.groovy

Lines changed: 30 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ class PollingConditionsSpec extends EmbeddedSpecification {
4444
}
4545
}
4646

47-
@PendingFeatureIf(value = { !data.conditionMethod }, reason = "Known limitation")
47+
@PendingFeatureIf(value = { !data.conditionMethod }, reason = "Known limitation, cannot know the used method is 'call' at runtime")
4848
@Retry
4949
def "succeeds if all conditions are eventually satisfied with condition method '#conditionMethod' and field"() {
5050
when:
@@ -106,11 +106,11 @@ class PollingConditionsSpec extends EmbeddedSpecification {
106106
conditionMethod << [".eventually", ".call", ""]
107107
}
108108

109-
@PendingFeatureIf(value = { !data.conditionMethod }, reason = "Known limitation")
109+
@PendingFeatureIf(value = { !data.conditionMethod }, reason = "Known limitation, cannot know the used method is 'call' at runtime")
110110
def "fails if any condition isn't satisfied in time with condition method '#conditionMethod' and field"() {
111111
when:
112112
runner.runSpecBody """
113-
PollingConditions conditions = new PollingConditions()
113+
PollingConditions conditions = new PollingConditions(timeout: 0.1)
114114
115115
volatile int num = 0
116116
volatile String str = null
@@ -140,7 +140,7 @@ class PollingConditionsSpec extends EmbeddedSpecification {
140140
volatile String str = null
141141
142142
def 'a feature'() {
143-
PollingConditions conditions = new PollingConditions()
143+
PollingConditions conditions = new PollingConditions(timeout: 0.1)
144144
num = 42
145145
146146
expect:
@@ -158,12 +158,12 @@ class PollingConditionsSpec extends EmbeddedSpecification {
158158
conditionMethod << [".eventually", ".call", ""]
159159
}
160160

161-
@PendingFeatureIf(value = { !data.conditionMethod }, reason = "Known limitation")
161+
@PendingFeatureIf(value = { !data.conditionMethod }, reason = "Known limitation, cannot know the used method is 'call' at runtime")
162162
@Issue("https://github.com/spockframework/spock/issues/413")
163163
def "reports failed condition of last failed attempt with condition method '#conditionMethod' and field"() {
164164
when:
165165
runner.runSpecBody """
166-
PollingConditions conditions = new PollingConditions()
166+
PollingConditions conditions = new PollingConditions(timeout: 0.1)
167167
168168
volatile int num = 0
169169
volatile String str = null
@@ -198,7 +198,7 @@ class PollingConditionsSpec extends EmbeddedSpecification {
198198
volatile String str = null
199199
200200
def 'a feature'() {
201-
PollingConditions conditions = new PollingConditions()
201+
PollingConditions conditions = new PollingConditions(timeout: 0.1)
202202
num = 42
203203
204204
expect:
@@ -224,7 +224,7 @@ class PollingConditionsSpec extends EmbeddedSpecification {
224224
def "fails if condition is not met and assert keyword is used for def declared conditions object with condition method '#conditionMethod' and field"() {
225225
when:
226226
runner.runSpecBody """
227-
def defConditions = new PollingConditions()
227+
def defConditions = new PollingConditions(timeout: 0.1)
228228
volatile int num = 0
229229
230230
def 'a feature'() {
@@ -248,7 +248,7 @@ class PollingConditionsSpec extends EmbeddedSpecification {
248248
def "fails if condition is not met and assert keyword is used for def declared conditions object with condition method '#conditionMethod' and local variable"() {
249249
when:
250250
runner.runSpecBody """
251-
def defConditions = new PollingConditions()
251+
def defConditions = new PollingConditions(timeout: 0.1)
252252
volatile int num = 0
253253
254254
def 'a feature'() {
@@ -268,13 +268,13 @@ class PollingConditionsSpec extends EmbeddedSpecification {
268268
conditionMethod << [".eventually", ".call", ""]
269269
}
270270

271-
@PendingFeature(reason = "Known limitation")
271+
@PendingFeature(reason = "Known limitation, cannot know the type of 'defConditions' at runtime")
272272
@Requires({ (GroovyRuntimeUtil.MAJOR_VERSION >= 3) || data.conditionMethod })
273273
@Issue("https://github.com/spockframework/spock/issues/1054")
274274
def "fails if condition is not met and assert keyword is not used for def declared conditions object with condition method '#conditionMethod' and field"() {
275275
when:
276276
runner.runSpecBody """
277-
def defConditions = new PollingConditions()
277+
def defConditions = new PollingConditions(timeout: 0.1)
278278
volatile int num = 0
279279
280280
def 'a feature'() {
@@ -294,13 +294,13 @@ class PollingConditionsSpec extends EmbeddedSpecification {
294294
conditionMethod << [".eventually", ".call", ""]
295295
}
296296

297-
@PendingFeature(reason = "Known limitation")
297+
@PendingFeature(reason = "Known limitation, cannot know the type of 'defConditions' at runtime")
298298
@Requires({ (GroovyRuntimeUtil.MAJOR_VERSION >= 3) || data.conditionMethod })
299299
@Issue("https://github.com/spockframework/spock/issues/1054")
300300
def "fails if condition is not met and assert keyword is not used for def declared conditions object with condition method '#conditionMethod' and local variable"() {
301301
when:
302302
runner.runSpecBody """
303-
def defConditions = new PollingConditions()
303+
def defConditions = new PollingConditions(timeout: 0.1)
304304
volatile int num = 0
305305
306306
def 'a feature'() {
@@ -320,8 +320,7 @@ class PollingConditionsSpec extends EmbeddedSpecification {
320320
conditionMethod << [".eventually", ".call", ""]
321321
}
322322

323-
@PendingFeatureIf(value = { !data.conditionMethod }, reason = "Known limitation")
324-
@Requires({ (GroovyRuntimeUtil.MAJOR_VERSION >= 3) || data.conditionMethod })
323+
@PendingFeatureIf(value = { !data.conditionMethod }, reason = "Known limitation, cannot know the used method is 'call' at runtime")
325324
def "can override timeout per invocation with condition method '#conditionMethod' and field"() {
326325
when:
327326
runner.runSpecBody """
@@ -419,8 +418,9 @@ class PollingConditionsSpec extends EmbeddedSpecification {
419418

420419
def "correctly creates timeout error message"() {
421420
given:
422-
PollingConditions conditions = new PollingConditions()
423-
conditions.onTimeout(onTimeoutClosure)
421+
def onTimeout = onTimeoutClosure == null ? null : PollingConditionsSpec."$onTimeoutClosure"
422+
PollingConditions conditions = new PollingConditions(timeout: 0.1)
423+
conditions.onTimeout(onTimeout)
424424

425425
when:
426426
conditions.eventually {
@@ -432,17 +432,19 @@ class PollingConditionsSpec extends EmbeddedSpecification {
432432
e.message ==~ /Condition not satisfied after \d+(\.\d+)? seconds and \d+ attempts/ + expectedMessageSuffix
433433

434434
where:
435-
onTimeoutClosure || expectedMessageSuffix
436-
null || ""
437-
noArgClosure || ": test"
438-
throwableArgClosure || ": ConditionNotSatisfiedError"
435+
onTimeoutClosure || expectedMessageSuffix
436+
null || ""
437+
"noArgClosure" || ": test"
438+
"throwableArgClosure" || ": ConditionNotSatisfiedError"
439439
}
440440

441441
def "correctly creates timeout error message when onTimeout called multiple times"() {
442442
given:
443-
PollingConditions conditions = new PollingConditions()
444-
conditions.onTimeout(onTimeoutClosure)
445-
conditions.onTimeout(secondOnTimeoutClosure)
443+
def onTimeout = onTimeoutClosure == null ? null : PollingConditionsSpec."$onTimeoutClosure"
444+
def secondOnTimeout = secondOnTimeoutClosure == null ? null : PollingConditionsSpec."$secondOnTimeoutClosure"
445+
PollingConditions conditions = new PollingConditions(timeout: 0.1)
446+
conditions.onTimeout(onTimeout)
447+
conditions.onTimeout(secondOnTimeout)
446448

447449
when:
448450
conditions.eventually {
@@ -454,9 +456,9 @@ class PollingConditionsSpec extends EmbeddedSpecification {
454456
e.message ==~ /Condition not satisfied after \d+(\.\d+)? seconds and \d+ attempts/ + expectedMessageSuffix
455457

456458
where:
457-
onTimeoutClosure | secondOnTimeoutClosure || expectedMessageSuffix
458-
noArgClosure | null || ""
459-
null | noArgClosure || ": test"
460-
throwableArgClosure | noArgClosure || ": test"
459+
onTimeoutClosure | secondOnTimeoutClosure || expectedMessageSuffix
460+
"noArgClosure" | null || ""
461+
null | "noArgClosure" || ": test"
462+
"throwableArgClosure" | "noArgClosure" || ": test"
461463
}
462464
}

0 commit comments

Comments
 (0)