You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: tck/README.md
+82-27
Original file line number
Diff line number
Diff line change
@@ -10,11 +10,11 @@ The TCK is implemented using **plain Java (1.6)** and **TestNG** tests, and shou
10
10
The TCK aims to cover all rules defined in the Specification, however for some rules outlined in the Specification it is
11
11
not possible (or viable) to construct automated tests, thus the TCK does not claim to completely verify an implementation, however it is very helpful and is able to validate the most important rules.
12
12
13
-
The TCK is split up into 4 files JUnit 4 test classes which should be extended by implementers, providing their `Publisher` / `Subscriber` implementations for the test harness to validate them. The tests are split in the following way:
13
+
The TCK is split up into 4 TestNG test classes which should be extended by implementers, providing their `Publisher` / `Subscriber` implementations for the test harness to validate them. The tests are split in the following way:
14
14
15
15
*`PublisherVerification`
16
-
*`SubscriberBlackboxVerification`
17
16
*`SubscriberWhiteboxVerification`
17
+
*`SubscriberBlackboxVerification`
18
18
*`IdentityProcessorVerification`
19
19
20
20
The next sections include examples on how these can be used and describe the various configuration options.
@@ -32,53 +32,65 @@ The TCK is provided as binary artifact on [Maven Central](http://search.maven.or
32
32
33
33
Please refer to the [Reactive Streams Specification](https://github.com/reactive-streams/reactive-streams-jvm) for the current latest version number. Make sure that the API and TCK dependency versions are equal.
34
34
35
-
### Types of tests
35
+
### Test method naming convention
36
36
37
37
Since the TCK is aimed at Reactive Stream implementers, looking into the sources of the TCK is well expected,
38
38
and should help during a libraries implementation cycle.
39
39
40
40
In order to make mapping between test cases and Specification rules easier, each test case covering a specific
41
-
Specification rule abides the following naming convention: `spec###_DESC` where:
41
+
Specification rule abides the following naming convention: `TYPE_spec###_DESC` where:
42
42
43
+
*`TYPE` is one of: [#type-required](required), [#type-optional](optional), [#type-stochastic](stochastic) or [#type-untested](untested) which describe if this test is covering a Rule that MUST or SHOULD be implemented. The specific words are explained in detail below.
43
44
*`###` is the Rule number (`1.xx` Rules are about Publishers, `2.xx` Rules are about Subscribers etc.)
44
45
*`DESC` is a short explanation of what exactly is being tested in this test case, as sometimes one Rule may have multiple test cases in order to cover the entire Rule.
The prefixes of the names of the test methods are used in order to signify the character of the test. For example, these are the kinds of prefixes you may find:
... means that the Rule is either racy, and/or inherently hard to verify without heavy modification of the tested implementation. Usually this means that this test case can yield false positives ("be green") even if for some case, the given implementation may violate the tested behaviour.
80
+
<aname="type-stochastic"></a>
81
+
The `stochastic_` means that the Rule is either racy, and/or inherently hard to verify without heavy modification of the tested implementation.
82
+
Usually this means that this test case can yield false positives ("be green") even if for some case, the given implementation may violate the tested behaviour.
... means that the test case is not implemented, either because it is inherently hard to verify (e.g. Rules which use the wording "*SHOULD consider X as Y*") or have not been implemented yet (though we hope we have implemented all we could!). Such tests will show up in your test runs as `SKIPPED`, with a message pointing out that the TCK is unable to validate this Rule. We would be delighted if you can figure out a way to deterministically test Rules, which have been marked with this prefix – pull requests are very welcome!
88
+
<aname="type-untested"></a>
89
+
The `untested_` means that the test case is not implemented, either because it is inherently hard to verify (e.g. Rules which use
90
+
the wording "*SHOULD consider X as Y*") or have not been implemented yet (though we hope we have implemented all we
91
+
could!). Such tests will show up in your test runs as `SKIPPED`, with a message pointing out that the TCK is unable to
92
+
validate this Rule. We would be delighted if you can figure out a way to deterministically test Rules, which have been
93
+
marked with this prefix – pull requests are very welcome!
82
94
83
95
### Test isolation
84
96
@@ -188,9 +200,12 @@ public class RangePublisherTest extends PublisherVerification<Integer> {
188
200
189
201
Notable configuration options include:
190
202
191
-
*`maxElementsFromPublisher` – which should only be overridden in case the Publisher under test is not able to provide arbitrary length streams, e.g. it's wrapping a `Future<T>` and thus can only publish up to 1 element. In such case you should return `1` from this method. It will cause all tests which require more elements in order to validate a certain Rule to be skipped,
192
-
*`boundedDepthOfOnNextAndRequestRecursion` – which should only be overridden in case of synchronous Publishers. This number will be used to validate if a
193
-
`Subscription` actually solves the "unbounded recursion" problem (Rule 3.3).
203
+
*`maxElementsFromPublisher` – which should only be overridden in case the Publisher under test is not able to provide
204
+
arbitrary length streams, e.g. it's wrapping a `Future<T>` and thus can only publish up to 1 element. In such case you
205
+
should return `1` from this method. It will cause all tests which require more elements in order to validate a certain
206
+
Rule to be skipped,
207
+
*`boundedDepthOfOnNextAndRequestRecursion` – which should only be overridden in case of synchronous Publishers.
208
+
This number will be used to validate if a `Subscription` actually solves the "unbounded recursion" problem (Rule 3.3).
194
209
195
210
### Timeout configuration
196
211
Publisher tests make use of two kinds of timeouts, one is the `defaultTimeoutMillis` which corresponds to all methods used
@@ -260,7 +275,7 @@ The `createElement` method MAY be called from multiple
260
275
threads, so in case of more complicated implementations, please be aware of this fact.
261
276
262
277
**Very Advanced**: While we do not expect many implementations having to do so, it is possible to take full control of the `Publisher`
263
-
which will be driving the TCKs test. You can do this by implementing the `createHelperPublisher` method in which you can implement your
278
+
which will be driving the TCKs test. This can be achieved by implementing the `createHelperPublisher` method in which you can implement your
264
279
own Publisher which will then be used by the TCK to drive your Subscriber tests:
265
280
266
281
```java
@@ -342,6 +357,7 @@ public class MySubscriberWhiteboxVerificationTest extends SubscriberWhiteboxVeri
342
357
// register a successful subscription, and create a Puppet,
343
358
// for the WhiteboxVerification to be able to drive its tests:
344
359
probe.registerOnSubscribe(newSubscriberPuppet() {
360
+
345
361
@Override
346
362
publicvoidtriggerRequest(longelements) {
347
363
s.request(elements);
@@ -356,18 +372,21 @@ public class MySubscriberWhiteboxVerificationTest extends SubscriberWhiteboxVeri
356
372
357
373
@Override
358
374
publicvoidonNext(Integerelement) {
375
+
// in addition to normal Subscriber work that you're testing, register onNext with the probe
359
376
super.onNext(element);
360
377
probe.registerOnNext(element);
361
378
}
362
379
363
380
@Override
364
381
publicvoidonError(Throwablecause) {
382
+
// in addition to normal Subscriber work that you're testing, register onError with the probe
365
383
super.onError(cause);
366
384
probe.registerOnError(cause);
367
385
}
368
386
369
387
@Override
370
388
publicvoidonComplete() {
389
+
// in addition to normal Subscriber work that you're testing, register onComplete with the probe
371
390
super.onComplete();
372
391
probe.registerOnComplete();
373
392
}
@@ -400,7 +419,7 @@ public class MySubscriberTest extends BlackboxSubscriberVerification<Integer> {
notVerified("Unable to implement test because ...");
548
+
@Override
549
+
publicPublisher<Integer>createFailedPublisher() {
550
+
returnnull; // returning null means that the tests validating a failed publisher will be skipped
501
551
}
502
552
503
553
}
504
554
```
505
555
506
-
## Upgrade story
556
+
## Upgrading the TCK to newer versions
557
+
While we do not expect the Reactive Streams specification to change in the forseeable future,
558
+
it *may happen* that some semantics may need to change at some point. In this case you should expect test
559
+
methods being phased out in terms of deprecation or removal, new tests may also be added over time.
507
560
508
-
**TODO** - What is our story about updating the TCK? How do we make sure that implementations don't accidentally miss some change in the spec, if the TCK is unable to fail verify the new behavior? Comments are very welcome, discussion about this is under-way in [Issue #99 – TCK Upgrade Story](https://github.com/reactive-streams/reactive-streams-jvm/issues/99).
561
+
In general this should not be of much concern, unless overriding test methods in your test suite.
562
+
We ask implementers who find the need of overriding provided test methods to reach out via opening tickets
563
+
on the `reactive-streams/reactive-streams-jvm` project, so we can discuss the use case and, most likely, improve the TCK.
509
564
510
565
## Using the TCK from other languages
511
566
@@ -542,4 +597,4 @@ class IterablePublisherTest(env: TestEnvironment, publisherShutdownTimeout: Long
542
597
543
598
Contributions to this document are very welcome!
544
599
545
-
If you're implementing reactive streams using the TCK in some language, please feel free to share an example on how to best use it from your language of choice.
600
+
When implementing Reactive Streams using the TCK in some language, please feel free to share an example on how to best use it from your language of choice.
0 commit comments