Skip to content

Commit 07ea4a1

Browse files
committed
+tck #232 explain which tests are mendatory to be "compliant"
1 parent b33420a commit 07ea4a1

File tree

1 file changed

+42
-18
lines changed

1 file changed

+42
-18
lines changed

tck/README.md

+42-18
Original file line numberDiff line numberDiff line change
@@ -102,10 +102,11 @@ In order to inform the TCK your Publisher is only able to signal up to `2` eleme
102102
}
103103
```
104104

105-
The TCK also supports Publishers which are not able to signal completion. For example you might have a Publisher being backed by a timer.
106-
Such Publisher does not have a natural way to "complete" after some number of ticks. It would be possible to implement a Processor which would
107-
"take n elements from the TickPublisher and then signal completion to the downstream", but this adds a layer of indirection between the TCK and the
108-
Publisher we initially wanted to test. We suggest testing such unbouded Publishers either way - using a "TakeNElementsProcessor" or by informing the TCK
105+
The TCK also supports Publishers which are not able to signal completion. For example you might have a Publisher being
106+
backed by a timer. Such Publisher does not have a natural way to "complete" after some number of ticks. It would be
107+
possible to implement a Processor which would "take n elements from the TickPublisher and then signal completion to the
108+
downstream", but this adds a layer of indirection between the TCK and the Publisher one initially wanted to test.
109+
It is suggested to test such unbouded Publishers either way - using a "TakeNElementsProcessor" or by informing the TCK
109110
that the publisher is not able to signal completion. The TCK will then skip all tests which require `onComplete` signals to be emitted.
110111

111112
In order to inform the TCK that your Publiher is not able to signal completion, override the `maxElementsFromPublisher` method like this:
@@ -217,12 +218,13 @@ The helper publisher is an asynchronous publisher by default - meaning that your
217218

218219
While the `Publisher` implementation is provided, creating the signal elements is not – this is because a given Subscriber
219220
may for example only work with `HashedMessage` or some other specific kind of signal. The TCK is unable to generate such
220-
special messages automatically, so we provide the `T createElement(Integer id)` method to be implemented as part of
221+
special messages automatically, so the TCK provides the `T createElement(Integer id)` method to be implemented as part of
221222
Subscriber Verifications which should take the given ID and return an element of type `T` (where `T` is the type of
222223
elements flowing into the `Subscriber<T>`, as known thanks to `... extends WhiteboxSubscriberVerification<T>`) representing
223224
an element of the stream that will be passed on to the Subscriber.
224225

225-
The simplest valid implemenation is to return the incoming `id` *as the element* in a verification using `Integer`s as element types:
226+
The simplest valid implemenation is to return the incoming `id` *as the element* in a verification using `Integer`s as
227+
element types:
226228

227229
```java
228230
public class MySubscriberTest extends SubscriberBlackboxVerification<Integer> {
@@ -235,16 +237,17 @@ public class MySubscriberTest extends SubscriberBlackboxVerification<Integer> {
235237
```
236238

237239

238-
The `createElement` method MAY be called from multiple
239-
threads, so in case of more complicated implementations, please be aware of this fact.
240+
The `createElement` method MAY be called from multiple threads, so in case of more complicated implementations, please
241+
be aware of this fact.
240242

241-
**Very Advanced**: While we do not expect many implementations having to do so, it is possible to take full control of the `Publisher`
242-
which will be driving the TCKs test. You can do this by implementing the `createHelperPublisher` method in which you can implement your
243-
own Publisher which will then be used by the TCK to drive your Subscriber tests:
243+
**Very Advanced**: While it is not expected for many implementations having to do so, it is possible to take full
244+
control of the `Publisher` which will be driving the TCKs test. You can do this by implementing the
245+
`createHelperPublisher` method in which you can implement your own Publisher which will then be used by the TCK to drive
246+
your Subscriber tests:
244247

245248
```java
246249
@Override public Publisher<Message> createHelperPublisher(long elements) {
247-
return new Publisher<Message>() { /* IMPL HERE */ };
250+
return new Publisher<Message>() { /* CUSTOM IMPL HERE */ };
248251
}
249252
```
250253

@@ -387,11 +390,14 @@ Note that hard-coded values *take precedence* over environment set values (!).
387390

388391
## Subscription Verification
389392

390-
Please note that while `Subscription` does **not** have it's own test class, it's rules are validated inside of the `Publisher` and `Subscriber` tests – depending if the Rule demands specific action to be taken by the publishing, or subscribing side of the subscription contract.
393+
Please note that while `Subscription` does **not** have it's own test class, it's rules are validated inside of the
394+
`Publisher` and `Subscriber` tests – depending if the Rule demands specific action to be taken by the publishing, or
395+
subscribing side of the subscription contract.
391396

392397
## Identity Processor Verification
393398

394-
An `IdentityProcessorVerification` tests the given `Processor` for all `Subscriber`, `Publisher` as well as `Subscription` rules. Internally the `WhiteboxSubscriberVerification` is used for `Subscriber` rules.
399+
An `IdentityProcessorVerification` tests the given `Processor` for all `Subscriber`, `Publisher` as well as
400+
`Subscription` rules. Internally the `WhiteboxSubscriberVerification` is used for `Subscriber` rules.
395401

396402
```java
397403
package com.example.streams;
@@ -448,12 +454,14 @@ public class MyIdentityProcessorVerificationTest extends IdentityProcessorVerifi
448454

449455
The additional configuration options reflect the options available in the Subscriber and Publisher Verifications.
450456

451-
The `IdentityProcessorVerification` also runs additional sanity verifications, which are not directly mapped to Specification rules, but help to verify that a Processor won't "get stuck" or face similar problems. Please refer to the sources for details on the tests included.
457+
The `IdentityProcessorVerification` also runs additional sanity verifications, which are not directly mapped to
458+
Specification rules, but help to verify that a Processor won't "get stuck" or face similar problems. Please refer to the
459+
sources for details on the tests included.
452460

453461
## Ignoring tests
454-
Since you inherit these tests instead of defining them yourself it's not possible to use the usual `@Ignore` annotations to skip certain tests
455-
(which may be perfectly reasonable if your implementation has some know constraints on what it cannot implement). We recommend the below pattern
456-
to skip tests inherited from the TCK's base classes:
462+
Since you inherit these tests instead of defining them yourself it's not possible to use the usual `@Ignore` annotations
463+
to skip certain tests (which may be perfectly reasonable if your implementation has some know constraints on what it
464+
cannot implement). We recommend the below pattern to skip tests inherited from the TCK's base classes:
457465

458466
```java
459467
package com.example.streams;
@@ -479,6 +487,22 @@ public class SkippingIdentityProcessorTest extends IdentityProcessorVerification
479487
}
480488
```
481489

490+
## Which verifications must be implemented by a compliant implementation?
491+
In order to be considered an Reactive Streams compliant require implementations to cover their
492+
Publishers and Subscribers with TCK verifications. If a library is only including
493+
Subscribers, it does not have to implement Publisher tests. The same applies to `IdentityProcessorVerification` -
494+
you do not need to implement it if the library does not contain Processors.
495+
496+
In the case of Subscriber Verification are two styles of verifications to available: Blackbox or Whitebox.
497+
It is *strongly* recommend to test `Subscriber` implementations with the `SubscriberWhiteboxVerification` as it is able to
498+
verify most of the specification. The `SubscriberBlackboxVerification` should only be used as a fallback,
499+
once you are sure implementing the whitebox version will not be possible for your implementation - if that happens
500+
feel free to open a ticket on the [reactive-streams-jvm](https://github.com/reactive-streams/reactive-streams-jvm) project explaining what stopped you from
501+
implementing the whitebox verification.
502+
503+
In summary: implementations are required to use Verifications for the parts of the specification that they implement,
504+
and suggest using the whitebox verification over blackbox for the subscriber whenever possible.
505+
482506
## Upgrade story
483507

484508
**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/issues/99).

0 commit comments

Comments
 (0)