Skip to content

Use most appropriate test assertion types #151

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

Merged
merged 1 commit into from
Jan 11, 2021

Conversation

per1234
Copy link
Contributor

@per1234 per1234 commented Jan 11, 2021

No description provided.

@per1234 per1234 requested review from rsora and silvanocerza January 11, 2021 06:06
@silvanocerza
Copy link
Contributor

I don't understand why this change is necessary, could you explain?

@per1234
Copy link
Contributor Author

per1234 commented Jan 11, 2021

The require package's assertion functions immediately terminate the test when the assertion fails. The assert package's assertion functions allow the test to continue when the assertion fails.

For this reason, the require functions should always and only be used when the failure of the assertion indicates that the results of all subsequent tests will be meaningless.

In cases where the failure of the assertion has no bearing on the results of subsequent tests, the assert functions should always be used so the test results can be as comprehensive as possible to allow all issues to be fixed before the next test run.

I didn't understand this when I started writing the tests, so I used inappropriate assertion functions in some places. There are likely some other sprinkled around, but I thought I'd at least clear out the ones I had been tracking on my "to do" list.

@silvanocerza
Copy link
Contributor

Ok, thanks for the explanation. I like this change.

The require package's assertion functions immediately terminate the test when the assertion fails. The assert package's
assertion functions allow the test to continue when the assertion fails.

For this reason, the require functions should always and only be used when the failure of the assertion indicates that
the results of all subsequent tests will be meaningless.

In cases where the failure of the assertion has no bearing on the results of subsequent tests, the assert functions
should always be used so the test results can be as comprehensive as possible to allow all issues to be fixed before the
next test run.
@per1234 per1234 force-pushed the per1234/test-assertion-types branch from b9cf210 to 88f96c5 Compare January 11, 2021 16:54
@per1234 per1234 merged commit e794fff into main Jan 11, 2021
@per1234 per1234 deleted the per1234/test-assertion-types branch January 11, 2021 17:04
@per1234 per1234 added topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project labels Sep 29, 2021
@per1234 per1234 self-assigned this Nov 20, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
topic: code Related to content of the project itself type: imperfection Perceived defect in any part of project
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants