Skip to main content
fyazı.1
Associate
June 10, 2020
Question

UNIT TEST FOR STM32 ?

  • June 10, 2020
  • 4 replies
  • 5245 views

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..

4 replies

AAgar.2
Associate III
June 10, 2020

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
fyazı.1Author
Associate
June 11, 2020

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
September 29, 2020

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.

Associate II
October 24, 2024

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.

Rock Deng
Associate III
October 30, 2024

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.