You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
You should generally use the standard UT_ASSERT macros for counting test statistics.
Here's why and how:
Why not UT_ASSERT_FATAL?
Test Termination:UT_ASSERT_FATAL immediately aborts the current test function upon failure. This prevents the rest of the test function from executing, potentially leaving resources uncleaned and making it harder to diagnose the full extent of the problem.
Limited Statistics: Since UT_ASSERT_FATAL stops the test early, it might not give you a complete picture of all the failures or errors that occurred within that test.
Why UT_ASSERT is Preferable:
Continues Execution:UT_ASSERT allows the test function to continue even if an assertion fails. This allows you to catch multiple failures within a single test and get a more comprehensive report of the issues.
Accurate Statistics: UT_Core automatically tracks the number of passes, failures, and errors for each test function and the overall test suite. Using UT_ASSERT ensures these statistics are accurate and reflect all the assertions made.
How to Count Stats with UT_ASSERT:
Write Test Functions: Use UT_ASSERT, UT_ASSERT_TRUE, UT_ASSERT_EQUAL, and other similar macros to make assertions within your test functions.
Retrieve Statistics: After the test suite finishes
Number of tests ran
Number of tests failed
Number of asserts
Number of failures
Number of errors
When to Use UT_ASSERT_FATAL (with Caution):
UT_ASSERT_FATAL can be useful in situations where a failure early in the test would render the rest of the test meaningless. For example, if a test relies on a resource that fails to initialize, you might use UT_ASSERT_FATAL to immediately abort the test and avoid misleading results.
Remember, use UT_ASSERT_FATAL sparingly and only when it's truly necessary to terminate the test early. In most cases, UT_ASSERT will provide you with more complete and accurate test statistics.
documentationImprovements or additions to documentation
1 participant
Heading
Bold
Italic
Quote
Code
Link
Numbered list
Unordered list
Task list
Attach files
Mention
Reference
Menu
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
You should generally use the standard
UT_ASSERTmacros for counting test statistics.Here's why and how:
Why not
UT_ASSERT_FATAL?Test Termination:
UT_ASSERT_FATALimmediately aborts the current test function upon failure. This prevents the rest of the test function from executing, potentially leaving resources uncleaned and making it harder to diagnose the full extent of the problem.Limited Statistics: Since
UT_ASSERT_FATALstops the test early, it might not give you a complete picture of all the failures or errors that occurred within that test.Why
UT_ASSERTis Preferable:Continues Execution:
UT_ASSERTallows the test function to continue even if an assertion fails. This allows you to catch multiple failures within a single test and get a more comprehensive report of the issues.Accurate Statistics: UT_Core automatically tracks the number of passes, failures, and errors for each test function and the overall test suite. Using
UT_ASSERTensures these statistics are accurate and reflect all the assertions made.How to Count Stats with
UT_ASSERT:Write Test Functions: Use
UT_ASSERT,UT_ASSERT_TRUE,UT_ASSERT_EQUAL, and other similar macros to make assertions within your test functions.Retrieve Statistics: After the test suite finishes
When to Use
UT_ASSERT_FATAL(with Caution):UT_ASSERT_FATALcan be useful in situations where a failure early in the test would render the rest of the test meaningless. For example, if a test relies on a resource that fails to initialize, you might useUT_ASSERT_FATALto immediately abort the test and avoid misleading results.Remember, use
UT_ASSERT_FATALsparingly and only when it's truly necessary to terminate the test early. In most cases,UT_ASSERTwill provide you with more complete and accurate test statistics.Beta Was this translation helpful? Give feedback.
All reactions