-
Notifications
You must be signed in to change notification settings - Fork 84
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
Update testing_boiler and unify test helpers #269
Update testing_boiler and unify test helpers #269
Conversation
Example message: Gamma::new was expected to succeed, but failed for shape=10.0, rate=NaN with error: 'Bad distribution parameters'
Example message: StudentsT::new was expected to fail, but succeeded for location=0.0, scale=10.0, freedom=1.0 with result: StudentsT { location: 0.0, scale: 10.0, freedom: 1.0 }
`test_case` -> `test_relative` `test_case_special` -> `test_absolute` Also improved the error messages
41ad04e
to
801542a
Compare
801542a
to
e335ad5
Compare
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## master #269 +/- ##
==========================================
- Coverage 90.62% 89.30% -1.33%
==========================================
Files 50 50
Lines 11583 10976 -607
==========================================
- Hits 10497 9802 -695
- Misses 1086 1174 +88 ☔ View full report in Codecov by Sentry. |
Just noticed I missed some |
The changed lines have 100% coverage, but total coverage still went down because the PR removes circa 700 lines. |
I really appreciate this, I think it'll add a lot of value for contributors to have a consistent approach for tests. I've no qualms with choices of names. I believe at this point, all arguments in I've reviewed the minimal functional changes to the boiler and I think it's fair to specify I believe that the only way this PR could allow behavior of the library to change in the future is if tests aren't the same, so my plan is to do some semantic diff and make sure everything in a pre-existing test module is a rename (or deletion, in the cases you footnote). Sound reasonable? |
Yeah, of course. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
reviewed locally, looks good!
I think the auto-merge broke something here, |
See #277. |
The unit tests are a bit messy at the moment. Duplicate code, subtly inconsistent behavior (
test_case
), bad naming, no documentation etc.I tried to clean it up a bit. This also makes the problems mentioned in #108 easier to spot (ctrl-f "test_exact"). List of changes:
try_create
andcreate_case
->create_ok
(dropped some verification but that really shouldn't matter1. If it does, I can change this)bad_create_case
->create_err
(new:create_err
returns the error, can be used for verification when more specific errors are returned)test_case
-> eithertest_exact
ortest_relative
, depending on old behavior (some implementations usedassert_eq
, others usedassert_relative_eq
)test_almost
->test_absolute
get_value
->create_and_get
#[should_panic]
tests to usetest_none
instead. Reads better IMHOThere are a few smaller things that could help further (re-enabling rustfmt for unit tests, dis-allowing
clippy::excessive_precision
), but those are less clear-cut, so I kept it to this changeset for now.Footnotes
The type of verification being done was extremely rudimentary, e.g.
let dist = Dist::new(7.5, 3.5);
and thenassert_eq!(dist.a(), 7.5);
plusassert_eq!(dist.b(), 3.5);
. ↩