-
Notifications
You must be signed in to change notification settings - Fork 217
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
simplify unit tests with utassert.h macros #397
Comments
These tests were originally implemented with an entirely different test framework, and we've been gradually trying to get them into the same model, but so far nobody has had time budget to rewrite them, so its been more of baby steps. |
A first pass would be just to update the "template" contained in the current unit test code. I can certainly do that and I suggest it get merged quickly so that future developments against the master branch follow the new paradigm. I'll do that. |
It would be a great help to update the "template", I've got some help coming soon that can address applying that template across the rest of the tests. Thanks @CDKnightNASA . |
confused why this was closed? |
Whoops. |
proposed re-write (wanted to get folks eyeballs on before I copy/paste it to all of the .c files. Or should we replace duplicates with a reference and have the template be in one file or in a separate file?) Note also I removed the test # from the text reported...Is the test # valuable? It becomes a maintenance issue if you're adding off-nominal tests or removing tests, as you have to re-number all of the assert texts below.
|
Maybe just implement a gold standard vs template (that way it's always up to date)? Or just drop it in a README vs actually in the *.c files? I don't think duplication is necessary. |
Please please please also include the actual value tested in all UtAssert_True statements whenever possible. We need useful log messages in the event of a failure. For instance, some of the other unit test code leverages a macro like this:
This, importantly, includes the actual numeric values within in the test log. The problem with something like |
Thinking about: #define UT_TEST_FUNC_RC(func,exp) UtAssert_True(func == exp, "%s != %s", #func, #exp) Numeric return codes are not all that useful/readable. And this doesn't require local scope/vars. |
No, the number is absolutely critical info for the poor soul who is assigned the task of debugging the failure. One can easily look up the error symbol based on the number, and then grep for code that returns that symbol. That at least gives you a starting point. Without this, you are left to reproduce the failure somehow in a debugger, which isn't always as trivial as it sounds. I've been there way too many times. This isn't realtime code; the most important thing should be to produce good, useful log output from a test that a developer can actually act on (even a little). |
To use the ever-applicable car analogy, this is like a "general car fault" light on the dashboard. When you go to the mechanic for a diagnosis, wouldn't you rather be able to say "I got a CAR_ERR_TEMP_TOO_HIGH error" rather than "I didn't get CAR_SUCCESS the last time I drove" ? Any failure of these tests is likely to come back to the CCB (us) for diagnosis, so we should include as much info to make our lives easier. |
Note the straw-man has the macros defined in osal/src/unit-tests/inc, it might make more sense to move these to osal/ut_assert/{inc|src}...Part of the discussion at the CCB. |
Fix #397, Remove old unit test example, add README.md, further macro cleanup
Is your feature request related to a problem? Please describe.
Currently a lot of OSAL unit test code is like the following (basically, run code, check the result, "force" an assert that it worked or didn't work):
Describe the solution you'd like
Instead, this can be simplified to:
Describe alternatives you've considered
A clear and concise description of any alternative solutions or features you've considered.
Additional context
Add any other context about the feature request here.
Requester Info
[email protected]
The text was updated successfully, but these errors were encountered: