feat: add require for critical checks #2812
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Using require for essential checks to ensure that tests do not proceed under invalid assumptions, while assert can be used for less critical checks to gather more information about potential issues.
Suggested Usage of assert and require :-
Critical Checks (Use require):
Use require to check critical conditions that must be true for the test to proceed.
If a require condition fails, the test stops immediately. This prevents any further code from running, which could lead to misleading error messages.
Non-Critical Checks (Use assert):
Use assert to evaluate conditions that are important but not critical for the test's overall success.
If an assert condition fails, the test continues to run, allowing multiple assertions to be evaluated.
Why is it important?
It is important to use require for critical conditions so that if a critical check fails, the test execution halts immediately. This prevents the test from continuing to run subsequent assertions, which may rely on the validity of the failed condition, thereby avoiding misleading error messages and ensuring that only relevant failures are reported. This approach enhances the clarity of test results and facilitates quicker identification of the root cause of issues.
Related issues