Get familiar with 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 simple example.
How to set up Ceedling
Ceedling is required to install ruby. I downloaded ruby for my windows10 here(https://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(https://osdn.net/projects/mingw/downloads/68260/mingw-get-setup.exe/). 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
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 led_controller.
3. Run Ceedling Unit Test for led_controller 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.
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.