Skip to content
This repository was archived by the owner on Feb 17, 2025. It is now read-only.

Conversation

@lycis
Copy link
Contributor

@lycis lycis commented Sep 6, 2024

Why

Sometimes you want to get an error from an assertion rather than directly fail a test run. Also test suites like Godog rely on returning an error instead of directly failing tests (e.g. because they encapsulate direct access to the test instance).

What

The FailureMessage type received a function AsError() that returns an instance of error or nil with the according failure message.

Checklist

  • CHANGELOG.md is updated.
  • README.md is updated.
  • The code changes follow Effective Go.
  • The code changes follow CodeReviewComments.
  • The code changes are covered by tests.

@lycis
Copy link
Contributor Author

lycis commented Sep 9, 2024

I like the suggest changes. I implemented them by:

  • Introducing the error-compatible type AssertionError
  • Refactoring AsError() to Err() to be more idiomatic.

@codecov
Copy link

codecov bot commented Sep 9, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 100.00%. Comparing base (7b197d1) to head (c02f19d).
Report is 1 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff            @@
##              main      #141   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           15        16    +1     
  Lines          438       444    +6     
=========================================
+ Hits           438       444    +6     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@pellared
Copy link
Member

pellared commented Sep 9, 2024

Thanks for your contribution. I plan to make a release today.

@pellared pellared changed the title Option to return an error from assertions instead of failing directly Add FailureMessage.Err method and AssertionError type Sep 10, 2024
@pellared pellared merged commit 83844e9 into fluentassert:main Sep 10, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants