ThrowTheSwitch / Unity

Simple Unit Testing for C
ThrowTheSwitch.org
MIT License
4.02k stars 969 forks source link

Intent of verbosity and command line parsing? #705

Closed jnz86 closed 10 months ago

jnz86 commented 10 months ago

At https://github.com/ThrowTheSwitch/Unity/blame/bf560290f6020737eafaa8b5cbd2177c3956c03f/src/unity.c#L2275 I see there are options to bring in command line arguments to the test main. Also there are also mentions of verbosity that modify a global variable, but it goes no where.

There are #ifdefed away until you #define UNITY_USE_COMMAND_LINE_ARGS.

I don't really get it. The only way to use any of this is to add the call manually to your main. And then verbosity at least does nothing anyhow. You need something like:


int main(int argc, char** argv)
{
    UNITY_BEGIN();

    (void) UnityParseOptions(argc, argv);

    RUN_TEST(xxx);
    RUN_TEST(yyy);

    return UNITY_END();
}

**_Intent_**?
mvandervoord commented 10 months ago

This is a feature that has been started but never really finished as it wasn't really in any demand (hence it's not in the documentation yet). We've found that when people want flexibility it what they're running, they tend to prefer it to happen in the test build manager (Ceedling, make, or whatnot) rather than built into the unity framework itself. So it's waiting for a decision.

jnz86 commented 10 months ago

Ah ok. Well, it's been 7 years so I'm going to bet you don't need it ;) But thanks for answering that. I thought I was missing something obvious.

mvandervoord commented 10 months ago

Actually, I'm wrong. I was just looking at this a few moments ago, and this feature is actually complete and running. It requires that you use the test runner generator to build your main for you. Ceedling actually is now taking advantage of this feature to do backtracing and finding which tests cause segfaults. :)

jnz86 commented 10 months ago

So, I saw someone using this with Ceedling. And I built with what the generator does... But I think the only way to get verbosity variable out would be to extern it in to another program? So... It's strange because you have a build command that tells Unity to build with x verbosity, but then you need to bring that in someone and make use of it. It seems more directly that Ceedling or some other program would just define and use it's own verbosity.

IDK. Either way, it's not for me! (I about bashed my head into the wall using Ceedling two weeks ago, so now I'm bashing my head into the wall with CMake and Gtest)

mvandervoord commented 10 months ago

:) Your answer tells me that we have a long way to go on explaining how things work together. Sorry to hear that you spent so much time heading down the wrong path. In either case, we appreciate the feedback! Best of luck! :)

jnz86 commented 10 months ago

I mean... I could go on for days how programmers are terrible at taking a single step back and explaining INTENT.

"We intended this to be used like this" is almost forbidden because "well you could use this lots of ways"... Yea, cool but tell me what you had in mind.

I like Unity, and hope I can make it work with CTest and integrated into VS Code. The only Unity extension for VS Code's native testing API is not well maintained. And Ceedling wasn't working inside a container for me. I'll come back around most likely.