Skip to content
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

Feature - add functionality to run single or multiple tests from one or multiple test files #736

Merged

Conversation

lukzeg
Copy link
Contributor

@lukzeg lukzeg commented Jan 20, 2023


FEATURE
Add possibility to execute single or multiple tests cases from one test file, or exclude some of test cases from test execution.

Base on request: #330 , #243


PR includes

Updated code :

  • Added new class UnityUtils.rb. (no code style issues - tested via rubocop)
  • Updated implementation of configurator_builder.rb
  • Updated implementation of generatior.rb
  • Updated implementation or rules_tests.rb

Updated CeedlingPacket.md with new ceedling functionality.

Added 5 UT to cover new functionality. ( rubocop describe problems with to long name description)


Short description

This PR contains extension which enable execution of:

  • one
  • or multiple tests
  • or non if the passed test case name is not fitting passed by end user parameter after colon

Referring to #330 , #243, the new functionality can be enabled by calling:

ceedling test:<test_file_name> --test_case=<test_case_name>

and updating project.yml after adding:

:test_runner:
  :cmdline_args: true

The UNITY_USE_COMMAND_LINE_ARGS will be set automatically by Ceedling as part of setup, so end user does not need to care about more setup.

Mentioned above functionality is an wrapper for functionality already delivered in Unity component( (UnityParseOptions)[https://github.com/ThrowTheSwitch/Unity/blob/master/src/unity.c#L2266]), and have his own limitations and problems.

Limitations and problems:

  • Can be at current moment executed for single test file
  • it passed test case name is a part of test_file_name.c, all tests will be executed from mentioned file.( The problem is connected with test runner generator which add test file name as part of test_case).

Information about such of issues are added to documentation.


** How it works in real life **

If test file contains three test cases:
test_gpio.c

#include "unity.h"
#include "gpio_def.h"

void setUp(void) {}
void tearDown(void) {}

void test_gpio_start(void) {
  TEST_ASSERT_EQUAL(GPIO_OK, gpio_start(gpio13) ).
}

void test_gpio_configure_proper(void) {
  TEST_ASSERT_EQUAL(GPIO_OK, gpio_configure(gpio_13, NULL));
}


void test_gpio_configure_fail_pin_not_allowed(void) {
  TEST_ASSERT_EQUAL(GPIO_ERR, gpio_configure(gpio_max, NULL));
}

and you want to run only:

  • configure tests, you can call ceedling test:gpio --test_case=configure
  • single test(require to be unique) call ceedling test:all --test_case=test_gpio_configure_fail_pin_not_allowed
  • all test cases from file ceedling test:gpio or ceedling test:all --test_case=gpio
  • to exclude test cases from test run with "configure" string, ```ceedling test:all --exclude_test_case

In case if test case name is not in the file name no test case will be executed.


@mvandervoord : Can I ask you for a looking at this in your free time? I have hope that this feature will help other people as helped me in my work.

@lukzeg lukzeg force-pushed the feature/add_one_test_run_possibility branch 2 times, most recently from 515fe0a to a49ce31 Compare January 25, 2023 15:26
@lukzeg
Copy link
Contributor Author

lukzeg commented Jan 25, 2023

Hi @mvandervoord,

If you will have time can you look at it, as I would like to expand a little bit more functionality of gdb_reported(to add possibility to collect results from tests which not crash from test_runner.c file) basing on this PR'st, but I'm not sure if it looks okay for you.

Enable posssibility to run single or multiple tests cases using:
   ceedling test:<test_file> --test_case=<test_case_name>

Enable filter for excluding test case name using --exclude_test_case arg:
   ceedling test:all --exclude_test_case=<test_case_name>

Update CeedlingPacket.md with information about new functionality
Add unit tests to confirm that functionality works with and without enabled cmd_args.
@lukzeg lukzeg force-pushed the feature/add_one_test_run_possibility branch from a49ce31 to c8efafd Compare January 25, 2023 16:42
@lukzeg lukzeg changed the title Feature - add functionality to run single or multiple tests from one test file Feature - add functionality to run single or multiple tests from one or multiple test files Jan 26, 2023
@mvandervoord
Copy link
Member

Hi @lukzeg -- I'm going to review this now. Before I even dive into it, I need to say three things:

  1. I'm really glad this feature is being worked on.
  2. I'm really thankful that you're working on it. You do great work.
  3. This is perhaps the best commented PR I've seen in my life!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants