phax / ph-commons

Java 11 Library with tons of utility classes required in all projects
Apache License 2.0
30 stars 18 forks source link

add tests for classes in com.helger.commons.io.stream package. #18

Closed dliang2000 closed 4 years ago

dliang2000 commented 4 years ago

Patrick Lam and I are doing some research on automatically proposing useful test cases for software systems. The idea is to add test cases for sibling classes in cases where some, but not all, of the siblings are tested. We believe there should be easy wins from proposing tests for uncovered methods in sibling classes C' of tested classes C.

This first commit targets easy examples where the system under test's methods are directly called from unit tests in a corresponding test class. It mirrors existing tests for NonBlockingStringWriter and NonBlockingByteArrayInputStream, and applies to their sibling classes.

We hope that you find these tests useful and would appreciate merging or comments with your thoughts on such tests.

codecov[bot] commented 4 years ago

Codecov Report

Merging #18 into master will increase coverage by 0.32%. The diff coverage is 37.50%.

Impacted file tree graph

@@             Coverage Diff              @@
##             master      #18      +/-   ##
============================================
+ Coverage     60.19%   60.52%   +0.32%     
- Complexity    12990    13050      +60     
============================================
  Files          1114     1114              
  Lines         43187    43195       +8     
  Branches       6442     6442              
============================================
+ Hits          25996    26143     +147     
+ Misses        15168    15002     -166     
- Partials       2023     2050      +27     
Impacted Files Coverage Δ Complexity Δ
...r/commons/io/stream/NonBlockingBufferedWriter.java 70.83% <37.50%> (+70.83%) 16.00 <4.00> (+16.00)
...elger/commons/io/stream/ByteBufferInputStream.java 71.42% <0.00%> (+38.09%) 16.00% <0.00%> (+9.00%)
...lger/commons/io/stream/ByteBuffersInputStream.java 50.00% <0.00%> (+50.00%) 19.00% <0.00%> (+19.00%)
.../commons/io/stream/NonBlockingCharArrayWriter.java 52.45% <0.00%> (+52.45%) 16.00% <0.00%> (+16.00%)

Continue to review full report at Codecov.

Legend - Click here to learn more Δ = absolute <relative> (impact), ø = not affected, ? = missing data Powered by Codecov. Last update d2207c3...397300e. Read the comment docs.

phax commented 4 years ago

Thank you @dliang2000 that is very cool :D What gives me the honour of you providing test cases?

phax commented 4 years ago

If you want suggestions on the code, here is one:

Use multi catch exceptions:

catch (final IllegalArgumentException | IOException ex)
{}

Or alternatively if it is an unexpected exception just add it to the signature