Get familiar with Ceedling

Photo by Andrew Neel on Unsplash

Get familiar with Ceedling

  • How to set up Ceedling

From last post, Ceedling was introduced as a unit testing framework for C. In this post, I want to show how to set up Ceedling and how to use Ceedling with the simple example.

  1. Ceedling is required to install ruby. I downloaded ruby for my windows10 here(rubyinstaller.org). By default, it is trying to install msys2 together. It is option and not required to run Ceedling. image.png

  2. After installed ruby, you can check version number by $ruby -v. ceedling version.JPG

  3. Now, you are ready to install Ceedling by $gem install ceedling. After installed ceedling, you can check version number by $ceedling version. ceedling version.JPG

  4. To run Ceedling, you need to have gcc.exe in your system. If you are in Windows, you may need to install MinGW(osdn.net/projects/mingw/downloads/68260/min..). Mark mingw32-base-bin and Installation>Apply changes.

Before MinGW installation: before mingw installation.JPG After MinGW installation after mingw installation.JPG Then, you need to update system path that windows can recognize gcc command. You may need to restart to apply this change in Windows. You can check if gcc is valid command by $gcc -v. gcc -v.JPG

edit environment variable for gcc.JPG Ceedling's command option can be found by $ceedling help. This would work without gcc.exe. ceedling command1.JPG

You will see different types of commands depending on where you are at. If Ceedling did not find any Ceedling project, it would show command options above. However, if you are under Ceedling project, it would show below:

image.png

  • How to use Ceedling
  1. Create Ceedling project: $ceedling new UnitTest This will create Ceedling project named UnitTest. If you want to create Ceedling project with Vendor's code and available plugins: $ceedling new UnitTest --local

  2. Create production code: $ceedling module:create[led_controller] This will create module named ledcontroller. ![image.png](cdn.hashnode.com/res/hashnode/image/upload/...png align="left")

  3. Run Ceedling Unit Test for ledcontroller module If you want to run all modules, $ceedling test:all In test file, if function name start with test, the function will be regarded as one test case. image.png

  • Conclusion

This post shows how to install Ceedling and how to use it. Next topic will show how to deal with dependency by using auto-generated mock by Ceedling. Next time, I will share led_controller unit test project.

Did you find this article valuable?

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