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 Improve coverage, fix bugs #4430

Merged
merged 2 commits into from
Aug 26, 2016
Merged

2.x Improve coverage, fix bugs #4430

merged 2 commits into from
Aug 26, 2016

Conversation

akarnokd
Copy link
Member

The new tests revealed some bugs (nothing major).

@akarnokd akarnokd added this to the 2.0 RC 2 milestone Aug 26, 2016
@codecov-io
Copy link

codecov-io commented Aug 26, 2016

Current coverage is 70.49% (diff: 60.29%)

Merging #4430 into 2.x will increase coverage by 0.98%

@@                2.x      #4430   diff @@
==========================================
  Files           454        454          
  Lines         32340      32371    +31   
  Methods           0          0          
  Messages          0          0          
  Branches       5217       5223     +6   
==========================================
+ Hits          22481      22820   +339   
+ Misses         7663       7422   -241   
+ Partials       2196       2129    -67   

Powered by Codecov. Last update 6dbeff4...57eda49

if (ex instanceof Error) {
throw (Error)ex;
}
if (ex instanceof RuntimeException) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

wrap handles this case

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The reason I inlined these here is because if I'm using propagate, that shows up in the code coverage analysis: the throw Exceptions.propagate(ex) never returns properly and thus the coverage thinks a code path is not covered. It is usually the last roadblock to a 100% covered file. I've been thinking about having ExceptionHelper.wrapOrThrow() that throws for non-checked and returns a wrapped checked that will run through throw.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sounds good to me. These exception helper methods could always return an unchecked exception forcing you to use throw and ensuring code coverage catches it.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Er, I guess that doesn't work for Error actually.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

    public static RuntimeException wrapOrThrow(Throwable error) {
        if (error instanceof Error) {
            throw (Error)error;
        }
        if (error instanceof RuntimeException) {
            return (RuntimeException)error;
        }
        return new RuntimeException(error);
    }

@JakeWharton
Copy link
Contributor

👍

@akarnokd
Copy link
Member Author

Updated those in the first commit in this PR and all other places that used Exceptions.propagate.

@JakeWharton
Copy link
Contributor

Looks good

@akarnokd akarnokd merged commit 0094304 into ReactiveX:2.x Aug 26, 2016
@akarnokd akarnokd deleted the Coverage826 branch August 26, 2016 18:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants