circleci / bond

spying for tests
127 stars 28 forks source link

Add called-once-with-args? and called-at-least-once-with-args? to bond/assertions #61

Closed Andrewwelton closed 3 years ago

Andrewwelton commented 3 years ago

On insights we noticed that the assertions available were often not flexible enough for us, and called-with-args is confusing without inspecting the source, and not useful on functions that are called many times through the course of a test (tracing/ methods, for example).

This adds called-once-with-args which we've written and use on Insights. We recognize that the same effect can be achieved with called-with-args and only providing the set of args we expect, but we've found the name and behaviour of the function confusing.

This also adds called-at-least-once-with-args? which is what we had expected called-with-args to be. This checks that the f provided was called with the provided arguments at least once.

I'd like to propose changing the called-with-args doc string to be more explicit about where and how it should be used, but wanted to propose this as a solution on it's own first.

Andrewwelton commented 3 years ago

Thanks for the feedback @calvis I'll make the changes you suggested :)

codecov[bot] commented 3 years ago

Codecov Report

Merging #61 (c09aa79) into main (6fe01e6) will increase coverage by 0.07%. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##             main      #61      +/-   ##
==========================================
+ Coverage   98.76%   98.83%   +0.07%     
==========================================
  Files           2        2              
  Lines          81       86       +5     
  Branches        1        1              
==========================================
+ Hits           80       85       +5     
  Partials        1        1              
Impacted Files Coverage Δ
src/bond/assertions.clj 100.00% <100.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 6fe01e6...c09aa79. Read the comment docs.

calvis commented 3 years ago

sorry was on vacation - i think the change to the implementation of called-once-with-args? still needs to happen, to drop the unnecessary call to called-times?, otherwise LGTM

Andrewwelton commented 3 years ago

sorry was on vacation - i think the change to the implementation of called-once-with-args? still needs to happen, to drop the unnecessary call to called-times?, otherwise LGTM

Thanks! I'll make that change shortly!