Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Global Contract Tests via Unit Tests #1962

Closed
benjchristensen opened this issue Dec 12, 2014 · 4 comments
Closed

Global Contract Tests via Unit Tests #1962

benjchristensen opened this issue Dec 12, 2014 · 4 comments
Milestone

Comments

@benjchristensen
Copy link
Member

I'm wondering if there is a way for us to create an AbstractTest class that we could implement for each operator that would have a series of specification tests, similar to a TCK that assert core behavior as opposed to the operator functionality.

For example:

  • subscribe and unsubscribe
  • request(Long.MAX_VALUE)
  • request(0)
  • request(n < 0)
  • request(n > 0)
  • scalar
  • vector
  • infinite
  • async and sync variants of each
  • concurrency (where applicable, such as unsubscribe and request)

It would require the implementation classes providing an Observable impl with each operator configured correctly for the various cases, but then the abstract portions could do the pounding and prove the basics for all operators.

This would be a great addition for someone looking to contribute. If someone has the time to tackle this I'd be happy to review the approach, specifications and tests while getting started. We should prove it on a few operators first before making the effort for all of them. For example map, take, merge, groupBy.

@akarnokd
Copy link
Member

And perhaps test for the special case of unsubscribe after onError or onCompleted not unsubscribing the downstream since I could do some async work after onError or onCompleted before I tell my downstream how to complete.

@abersnaze
Copy link
Contributor

I've been thinking about a general operator testing as well. I think we'll need an alternate iterable implementation of the each operator to use as the expected behavior to assert against.

actual = Observable.from(input).lift(observableOp).toList().toBlocking().single()
expected = iterableOp.call(input)

@davidmoten
Copy link
Collaborator

I've had a play with this one. It's not fully unit tested but appears to be working so far and I'm already finding this very useful for testing custom Operators. This may not be what people are envisaging but might nethertheless be useful for pushing discussion.

The page below demos a sync test for count and an async test for merge.

https://github.com/davidmoten/rxjava-extras

@benjchristensen benjchristensen added this to the 2.0 milestone Aug 28, 2015
@benjchristensen
Copy link
Member Author

Closing in favor of #2783 for 2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants