- 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.
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.
After installed ruby, you can check version number by $ruby -v.
Now, you are ready to install Ceedling by $gem install ceedling. After installed ceedling, you can check version number by $ceedling version.
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: After MinGW installation 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.
Ceedling's command option can be found by $ceedling help. This would work without gcc.exe.
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:
- How to use Ceedling
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
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")
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.
- 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.