Posts
TDD Example - writing software spec and test cases
- Get link
- X
- Other Apps
Before starting TDD, I need software spec and test cases. My goal is demonstrating software development process with a simple example:fizzbuzz problem. Here is software spec for fizzbuzz problem: 1. if given number is divided up by 3, print fizz. 2. if given number is divided up by 5, print buzz. 3. if given number is divided up by both 3 and 5, print fizz buzz. 4. otherwise, print given number. From software spec, you can easily derive test cases based on different outputs. In this case, function's behavior is driven test cases: 1. Print fizz when input is 3 2. Print buzz when input is 5 3. Print fizz buzz when input is 15 4. Print given number Don't get stressed by writing test spec at first. It does not have to be perfect. It can be always enhanced during TDD cycle. We can start to create ceedling project named "fizzbuzz_unittest" and create module named "fizzbuzz". Let's start to write test code based on simple...
Ceedling workspace in Visual Studio Code
- Get link
- X
- Other Apps
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. Visual Studio Code with Ceedling plug-in can make this process easier.
Ceedling: mock hardware software interface by using StubWithCallback
- Get link
- X
- Other Apps
Auto generated mock files in Ceedling provides Ignore and Expect functions as well as StubWithCallback function. StubWithCallback demonstrates hardware software interface. For example, external EEPROM can be accessed via specific SPI command such as read byte and write byte. It means that there is no direct way to access EEPROM contents. It would be nice to access EEPROM during unit testing. To do this, define simulated EEPROM in host RAM and the read byte function and write byte function should be implemented as StubWIthCallback. I learned this Ceedling feature from this blog( http://www.electronvector.com/blog/unit-testing-with-flash-eeprom ).
Ceedling: Dealing With Dependency Issue Between Modules
- Get link
- X
- Other Apps
Unit Testing in Embedded System?
- Get link
- X
- Other Apps
This was an unusual topic to me at first while I have worked as firmware engineer for microcontrollers. Most of microctonroller applications are still developed in C or C++. In the past, while you developed something in C, you barely heard about unit testing. You needed to research a long time to set up a unit testing environment. At this moment, the most popular one might be Unity or CPPUtest, but they are not easy to use when the code has complex dependency upon each other because you need to create mock objects to your own manually. The importance of unit testing has been popular recently with newer high level languages such as Java and C#. Those languages have standard unit testing framework. Java has JUnit and Visual Studio provides a unit testing framework for C#. Unfortunately, C was developed before the rising popularity of unit testing and it did not come up with standard unit testing framework.