-
-
Notifications
You must be signed in to change notification settings - Fork 601
[Enhancement]: use testify's require instead of assert. #2808
Description
Proposal
TL;DR: use
requirewhen a failure should stop the test completely, ensuring that subsequent steps are not executed with invalid assumptions. Useassertwhen we want to evaluate all assertions, even if some fail, to provide more comprehensive feedback on test results.
Why?
By using require for crucial checks, we can avoid misleading error messages from failed assertions that come later in the test after an essential condition has already failed. This makes the root cause of the failure easier to diagnose, as the test execution halts as soon as the condition fails, preventing further unnecessary execution of test logic that depends on the success of the failed condition. This can save time, especially in long or complex tests, where subsequent steps may not be relevant after a failure.
assert, on the other hand, might allow tests to continue, resulting in multiple failures and potentially obscuring the real cause.