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

2.x: BaseObserver.assertOnlyValues(T...) #5555

Closed
vanniktech opened this issue Aug 18, 2017 · 6 comments
Closed

2.x: BaseObserver.assertOnlyValues(T...) #5555

vanniktech opened this issue Aug 18, 2017 · 6 comments

Comments

@vanniktech
Copy link
Collaborator

I'd like to introduce assertOnlyValues to the BaseObserver. It's the counterpart to assertResult(T...) which does almost the same except for the fact that the type hasn't completed yet.

I'm open if anyone has a better function name. Internally it'd delegate to:

  assertValues(values)
      .assertNoErrors()
      .assertNotComplete()
      .assertSubscribed();
@akarnokd
Copy link
Member

assertResult will eventually fail so assertValues was generally enough. When there is a bug, you can apply the other methods on a case by case basis.

@vanniktech
Copy link
Collaborator Author

assertResult will eventually fail so assertValues was generally enough.

Although assertValues does not check for errors nor it'll fail when the stream does complete. Basically with that method I want to test that the stream will stay alive and not terminate.

@akarnokd
Copy link
Member

You can write this utility method in a class:

public static <T, U extends BaseTestConsumer<T>> assertValuesOnly(U ts, T... values) {
    return ts.assertValues(values).assertNoErrors().assertNotComplete().assertSubscribed();
}

And IntelliJ will happily staticly import it.

@artem-zinnatullin
Copy link
Contributor

I tend to agree with @vanniktech on this feature-request.

When there is a bug, you can apply the other methods on a case by case basis.

It's usually too late because code was shipped…

You can write this utility method in a class:

For sure, I'm also pretty sure @vanniktech uses Kotlin so he could add extension function.

Not a fan of naming though, but I see the pattern, assertOnlyValues() should fit test API design.

@vanniktech
Copy link
Collaborator Author

For sure, I'm also pretty sure @vanniktech uses Kotlin so he could add extension function.

That's what I'm doing right now. However I still think a lot of other people could benefit from this and the cost of adding this is really low.

Not a fan of naming though, but I see the pattern, assertOnlyValues() should fit test API design.

Open for any better name.

@akarnokd
Copy link
Member

Okay, let's add it.

I'd name it assertValuesOnly so it should show up right after assertValues in code completion.

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

3 participants