ThrowTheSwitch / Ceedling

Ruby-based unit testing and build system for C projects

Home Page:http://throwtheswitch.org

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Could I run only one test_ function within one test file?

kafkaaaa opened this issue · comments

Good Morning!

Could I run only one test_ function within one test file?

or should I create another test file in the src directory?

Happy Coding ~ 😊

Yes.

First, you need to enable the feature (it introduces a bit of overhead to each test executable, so it's disabled by default). Add this to your project.yml file:

:test_runner:
  :cmdline_args: TRUE

Now, from the command line, you can issue tests like this:

ceedling test:FILE --test_case=test_this_is_the_test_case_I_want_to_run

where FILE is the name of the file that contains the test and test_this_is_the_test_case_i_want_to_run is the test within that file that is desired.

If the test case matches more than one test, it'll run each of them. For example, --test_case=test_stuff would run all the following tests:

void test_stuff(void)
void test_stuff_and_verify_it_works(void)
void test_stuff_again(void)

But would not run these:

void test_more_stuff(void)
void test_other_things_that_do_not_contain_stuff_yet(void)

Finally, there's a similar option called --exclude_test_case which runs all the tests that do NOT match the name specified... so the opposite of the above.

All of these features are on the Release Candidate branch. I don't recall at the moment if they were in the 0.31 release of Ceedling.

I think the features might not be present in the 0.31 release. When I try it, including the added define mentioned in #747, it still runs all the tests in a file

We are nearing an official release of 0.32. I can confirm that running individual test cases works as expected when :test_runner ↳ :cmdline_args is set to true.