Ceedling with Visual Studio Code

Test Driven Development is required to go through multiple times of small changes in production code and test code concurrently. It would be nice to have GUI IDE to load all files in one workspace. Also, you might want to debug test code during run-time instead of stepping through line by line with gdb command(ceedling default). Visual Studio Code with Ceedling plug-in can make this process so much easier!

  • Setup Development Environment
  1. Download Visual Studio Code (It supports all OS: Windows, Linux, Mac OS.)

  2. Download Ceedling plug-in

  3. Download C/C++ plug-in

  4. Open Ceedling project folder in Visual Studio Code image.png

  5. Edit project.yml file image.png

  • Run test with Visual Studio Code

You can see test files are loaded with each test cases. If you want to run all tests, you can click play button. image.png This action is equivalent with command line: ceedling test:all

If you wan to test led_controller, you can find play button while hover on led_controller. image.png This action is equivalent with command line: ceedling test:led_controller

This project can be saved as workspace. Next time, you can open workspace to continue work on TDD. image.png

  • Debug the test code with Visual Studio Code
  1. Go to Setting(highlighted cogwheel) and search "Ceedling". image.png

  2. Click Workspace and update Debug Configuration as ceedlingExplorer. Create folder named .vscode and create launch.json under. Debug will look for ceedlingExplorer and you can find this name in launch.json. image.png This setup is from github.com/numaru/vscode-ceedling-test-adap... We need to choose which test file to debug @"program". Currently, my scope is test_led_controller.out. This will allow me to place breakpoints in test file which is test_led_controller.c:

  3. Add breakpoint(click line number) in test_led_controller.c and click Debug image.png


Debugger is stopped at breakpoint! All set up is done now. Now, we can write test code and run to fail and write production code and re-run test to pass by clicking without typing ceedling command on command line anymore. Happy TDD!

Did you find this article valuable?

Support Hyunwoo Choi by becoming a sponsor. Any amount is appreciated!