Ceedling icon indicating copy to clipboard operation
Ceedling copied to clipboard

Ceedling TEST_CASE does not work with blinky

Open professor-frink opened this issue 2 years ago • 1 comments

Good morning,

Given the following setup:

  • Windows 10 PC
  • mingw installed to C:\mingw\bin
  • gcc version: gcc (MinGW.org GCC-6.3.0-1) 6.3.0
  • Ruby version: ruby 2.4.1p111 (2017-03-22 revision 58053) [x64-mingw32]
  • Ceedling:: 0.31.1
  • CMock:: 2.5.4
  • Unity:: 2.5.4
  • CException:: 1.3.3

Problem: I get undefined/differeng TEST_CASE values in the failed test assertion versus the test I wrote

Steps to reproduce:

  1. Modify project.yml to point to C:\mingw\bin
  2. I modified test_main.c to be as follows adding a new parametric test, "test_actual_value": #include "unity.h" #include "main.h" #include "stub_io.h" #include "mock_Configure.h" #include "mock_BlinkTask.h" #define TEST_CASE(...) void setUp(void) {} // every test file requires this function; // setUp() is called by the generated runner before each test case function void tearDown(void) {} // every test file requires this function; // tearDown() is called by the generated runner before each test case function

// test_main.c as is... TEST_CASE(5) void test_actual_value(int actual) { int expected = 1; TEST_ASSERT_EQUAL(expected,actual); }

After issuing ceedling test:main I get a failure, but not with the test case I injected

Test 'test_main.c'


Generating include list for Configure.h... Generating include list for BlinkTask.h... Creating mock for Configure... Creating mock for BlinkTask... Generating runner for test_main.c... Compiling test_main_runner.c... build/test/runners/test_main_runner.c: In function 'main': build/test/runners/test_main_runner.c:97:12: warning: passing argument 1 of 'run_test' from incompatible pointer type [-Wincompatible-pointer-types] run_test(test_actual_value, "test_actual_value", 64); ^~~~~~~~~~~~~~~~~ build/test/runners/test_main_runner.c:60:13: note: expected 'UnityTestFunction {aka void ()(void)}' but argument is of type 'void ()(int)' static void run_test(UnityTestFunction func, const char* name, UNITY_LINE_TYPE line_num) ^~~~~~~~ Compiling mock_Configure.c... Compiling mock_BlinkTask.c... Linking test_main.bin... Running test_main.bin...


FAILED TEST SUMMARY

[test_main.c] Test: test_actual_value At line (67): "Expected 1 Was 4272392"

After commenting out :use_test_preprocessor:, the actual value used in the test changes from 427392 to the expected 5.

Question

  1. Why is this the case?
  2. Am I doing something wrong in implementing TEST_CASE? I can't find any documentation on TEST_CASE, or use_test_preprocessor, or TEST_RANGE in the Ceedling documentation. Am I looking in the wrong place?

Thanks!

professor-frink avatar Nov 11 '22 17:11 professor-frink

Hi, you can try the solution from ceedling mailing list: https://groups.google.com/g/throwtheswitch/c/wV0XNS5FcV0

CezaryGapinski avatar Jan 01 '23 19:01 CezaryGapinski