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

Add more built-in matchers to the Cadence Testing Framework #2420

Merged

Conversation

m-Peter
Copy link
Contributor

@m-Peter m-Peter commented Apr 4, 2023

Work towards: onflow/developer-grants#148

Description

Implements the matchers described in #1889


  • Targeted PR against master branch
  • Linked to Github issue with discussion and accepted design OR link to spec that describes this work
  • Code follows the standards mentioned here
  • Updated relevant documentation
  • Re-reviewed Files changed in the Github PR explorer
  • Added appropriate labels

@codecov
Copy link

codecov bot commented Apr 4, 2023

Codecov Report

Merging #2420 (74dc043) into master (41f75d7) will decrease coverage by 0.02%.
The diff coverage is 96.55%.

@@            Coverage Diff             @@
##           master    #2420      +/-   ##
==========================================
- Coverage   78.60%   78.58%   -0.02%     
==========================================
  Files         316      315       -1     
  Lines       68848    68886      +38     
==========================================
+ Hits        54118    54135      +17     
- Misses      12928    12943      +15     
- Partials     1802     1808       +6     
Flag Coverage Δ
unittests 78.58% <96.55%> (-0.02%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
runtime/stdlib/test.go 54.23% <96.55%> (+9.87%) ⬆️

... and 24 files with indirect coverage changes

Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here.

@turbolent turbolent self-assigned this Apr 4, 2023
Copy link
Member

@turbolent turbolent left a comment

Choose a reason for hiding this comment

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

Nice!

Copy link
Member

@turbolent turbolent left a comment

Choose a reason for hiding this comment

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

Great work! 👌

Co-authored-by: Supun Setunga <supun.setunga@gmail.com>
Comment on lines +1574 to +1578
elementFound = value.ContainsKey(
inter,
invocation.LocationRange,
element,
)
Copy link
Member

@turbolent turbolent Apr 11, 2023

Choose a reason for hiding this comment

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

Maybe this should check both keys and values? Then again, e.g. testify's assert.Contains also only checks map keys 🤔

In Hamcrest there seem to be dedicated functions for testing arrays and dictionaries.

Copy link
Member

Choose a reason for hiding this comment

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

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it seems that the Go implementation inspired by Hamcrest, has also dedicated matchers for arrays and dictionaries:

  • is.ArrayContaining(expected)
  • is.ArrayMatching(expected)
  • is.MapContaining(expected)
  • is.MapContainingValues(expected)
  • is.MapMatchingValues(expected)

Supun noted this as well. What do you think should be the way to go about this? Do you have any desired API in mind?

@turbolent turbolent merged commit 1541525 into onflow:master Apr 11, 2023
@m-Peter m-Peter deleted the testing-framework-add-more-matchers branch April 13, 2023 13:42
@m-Peter m-Peter mentioned this pull request Apr 19, 2023
17 tasks
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