## Intro My approach to explaining how it works will start with a simple project and gradually complicate it step by step until we have full control of the unit test process. ## Create Project From Scratch As mentioned before, Ceedling is a build system that provides a way to create a project, modules, and test files in a structured manner, making it easy to run tests later. :::info To create a new project: ::: ```bash # ceedling new yourProjectName ceedling new VectorDotProduct ``` Output: ```bash $> ceedling new VectorDotProduct Welcome to Ceedling! create VectorDotProduct/project.yml Project 'VectorDotProduct' created! - Execute 'ceedling help' from VectorDotProduct to view available test & build tasks ``` Ceedling will generate the skeleton for starting a new project called `VectorDotProduct`. ## Ceedling Options :::info You can skip this section for now ::: - `--local` This option allows you to bind your tools and project by allowing them to be used without worrying about external dependencies. This means that if Ceedling changes for this particular project because you updated your gems, you don’t have to worry about Unity breaking your build in the future. To use this option: ```bash ceedling new --local VectorDotProduct ``` - `--docs` If you're new to Ceedling, you can install handy documentation alongside your project. To do this: ```bash ceedling new --docs VectorDotProduct ``` - `--gitignore` If you're using git it will ignore the build files. ## Ceedling Project Structure ```bash $ tree -L 1 . (VectorDotProduct) ├── project.yml ├── src └── test ``` :::info The structure contains: ::: - `src`: Contains your project files (headers and source files). - `test`: Contains the test files only. Each test file should start with `test_baseName.c`. - `project.yml`: Holds the configuration for Ceedling (e.g., test files are in the `test` folder, source and header files are in the `src` folder, etc.). - `build`: After running your first build, this directory will be generated where the tests are built. - `vendor`: Contains Ceedling source files (only generated if you use the `--local` option when creating a project). ## Create Our First Module `vectorDotProduct` :::info #### Create It Manually ::: 1. Go to `VectorDotProduct/src` 2. Create `vectorDotProduct.c` and `vectorDotProduct.h` 3. Go to `VectorDotProduct/test` 4. Create `test_vectorDotProduct.c` :::info #### Create It Using Ceedling ::: In a terminal: ```bash # Navigate to the VectorDotProduct directory cd VectorDotProduct # Run ceedling module:create[path/name] ceedling module:create[vectorDotProduct] ``` Output: ```bash File src/vectorDotProduct.c created File src/vectorDotProduct.h created File test/test_vectorDotProduct.c created Generate Complete ``` ### Notes - As mentioned earlier, the test file must start with `test_`, as this is configured in `project.yml`. - ![test_ in yml configuration](https://hackmd.io/_uploads/r13NV2PWJg.png) - The locations of the source and header files are configured in `project.yml`. ![image](https://hackmd.io/_uploads/HJQw43D-yg.png) In this article, we learned how to create a new project using Ceedling, the project structure, and how to create a new module. In the next tutorial, we will write our first test case using the Unity framework.