cancel
Showing results for 
Search instead for 
Did you mean: 

UNIT TEST FOR STM32 ?

fyazı.1
Associate II

Hi, 

I wanna use TDD on my projects. So; I try implement CppUTest or Unity Test Frameworks but i couldn't do it. Is there anyone use this test framework on STM32CUBEIDE? What could be wrong? When i try build project , i get so many errors. (like : no such file or directory...)

if there is a tutorial for beginning TDD for STM32CubeIde , it would be so helpful.

Best Regards..

5 REPLIES 5
AAgar.2
Associate III

I use unity.

The console print in the lib is an issue. Disable console prints.

File not found will just be an issue of paths. Check again.

fyazı.1
Associate II

Hi,

Thanks for your response. Sorry i couldn't understand "console prints" exactly. Did you mention "UnityPrint" functions? Is there a #define for disable all console print functions?

And when i add simple code i get this errors >> undefined reference to 'UnityBegin' , undefined reference to 'UnityEnd' ... . I added screenshot too.

/* USER CODE BEGIN Includes */

#include "../../Unity/src/unity.h"

#include "../../Unity/src/unity_internals.h"

/* USER CODE END Includes */

int main(void)

{

  UNITY_BEGIN();

  int a = 1;

  TEST_ASSERT( a == 1 ); //this one will pass

  TEST_ASSERT( a == 2 ); //this one will fail

  return UNITY_END();

}

0693W000001qY1pQAE.png

MMich.2
Associate II

I'm also very interested in integrating tests inside the STM32CubeIDE. I have asked a similar question since the UI actually shows a checkbox to add unit tests.

EvO
Associate II

I am using cpputest and am running it from the command line. Just type make after every test/refactor. This works with any IDE, because the tests run on the pc, not on the STM. If you carefully design your software (i.e. keep everything hardware-related separate), this work very efficiently. You don't even need hardware until the software is nearly finished :)

So I just use a console window in STM Cube to make the tests, rather than trying to use anything integrated.

Best regards,
Edwin

It's great to hear that someone has implmented cpputest in the Cube ecosystem successfully. I've been trying to do the similar thing recently.