title: Unit Testing a project that uses an RTOS
body: <p>For my next embedded systems project I want to embrace unit testing. It may not technically be test driven development, but I would at least like to instrument unit tests up front and have comprehensive unit testing.</p>
  
  <p>I am using the IAR EWARM tool chain. I am considering using cmocka, unity, or cunit. I am learning towards using µC/OS-III as the RTOS.</p>
  
  <p><strong>Here's the question:</strong> How is unit testing going to work with an RTOS in the picture? E.G: Should I disable the kernel and unit test the code as a single threaded application and stub all/most kernel calls, or is there a better way?</p>
  
  <p><strong>Example:</strong>
  In µC/OS-III the entry point is still main. From main you call any init code and then make a call to OSStart() to begin multitasking. So when I am running the test harness I could just not make the call to OSStart() </p>
  
  <pre><code>#ifdef UNIT_TEST
  test_runner();
  #else
  OSStart(&amp;err);
  #endif
  </code></pre>
  
  <p>Then in all of my application code in the tasks I would just need to mock message passing and delay calls to the kernel.</p>
  
  <p>Is that the best way to do this. Or would I be better suited starting the kernel, creating a task for my test runner, and running all of the tasks from that as a single thread, or is there some other good approach involving spawning the other tasks from the test harness.</p>