user34045: I'm working on a little Arduino game project that uses neopixel strips as a display. Uploading every code change to the Arduino and testing it on the LEDs is slow and drains hardware lifetime.
Usually I test as much I can using the Serial Monitor, but I can't get it to clear from code which I learned is only possible e.g. when using a terminal. I did that, but it comes with other issues.
Is there a better way to test code on the dev machine instead of the Arduino?
Is there a best practice to have a Serial Monitor (or anything else) act like a display that I can actually refresh/clear? Serial.println() empty lines to scroll the content is not very practical.

user19867: You can unit test your code by creating stubs of the functions you are calling, like replacing a couple of includes with their dumb counterparts.
My friend Jan Beayens did something very valuable on that front and he is also the main author of a good replacement for the Arduino IDE when you start needing some more advanced capabilities: Sloeber is the product name and it also contains an improved version of the serial monitor with clear and scroll lock capabilities.
Go check it out.
Disclaimer : I'm a contributor of the project

user42393: As you've probably noticed, trying to run tests over the serial port is frustrating.  Worse, the relatively large delays associated with writing serial data can affect the accuracy of your measurements.
To cope with this, I wrote my own unit testing framework for Arduino, which lets you fully mock (simulate) the hardware so that you can verify the operation of the software.  
There are some examples of how my library accomplishes that, in the project README.  Here is one for pins:
unittest(pin_history)
{
  GodmodeState* state = GODMODE();
  int myPin = 3;
  state->reset();            // pin will start LOW
  digitalWrite(myPin, HIGH);
  digitalWrite(myPin, LOW);
  digitalWrite(myPin, LOW);
  digitalWrite(myPin, HIGH);
  digitalWrite(myPin, HIGH);

  assertEqual(6, state->digitalPin[1].size());
  bool expected[6] = {LOW, HIGH, LOW, LOW, HIGH, HIGH};
  bool actual[6];

  // convert pin history to an array, and verify expected results
  int numMoved = state->digitalPin[myPin].toArray(actual, 6);
  assertEqual(6, numMoved);

  // verify each element
  for (int i = 0; i < 6; ++i) {
    assertEqual(expected[i], actual[i]);
  }
}

You may also like the example for mocking Serial port data, although I probably need to improve that documentation.
The beauty of all this is that I was able to develop this framework and all these tests without ever plugging an Arduino board into my computer. 

34045: <p>I'm working on a little Arduino game project that uses neopixel strips as a display. Uploading every code change to the Arduino and testing it on the LEDs is slow and drains hardware lifetime.</p>

<p>Usually I test as much I can using the Serial Monitor, but I can't get it to clear from code which I learned is only possible e.g. when using a terminal. I did that, but it comes with other issues.</p>

<p>Is there a better way to test code on the dev machine instead of the Arduino?
Is there a best practice to have a Serial Monitor (or anything else) act like a display that I can actually refresh/clear? Serial.println() empty lines to scroll the content is not very practical.</p>
 19867: <p>You can unit test your code by creating stubs of the functions you are calling, like replacing a couple of includes with their dumb counterparts.
My friend Jan Beayens did something very valuable on that front and he is also the main author of a good replacement for the Arduino IDE when you start needing some more advanced capabilities: <a href="http://sloeber.io" rel="nofollow noreferrer" title="Sloeber">Sloeber</a> is the product name and it also contains an improved version of the serial monitor with clear and scroll lock capabilities.</p>

<p>Go check it out.</p>

<p>Disclaimer : I'm a contributor of the project</p>
 42393: <p>As you've probably noticed, trying to run tests over the serial port is frustrating.  Worse, the relatively large delays associated with writing serial data can affect the accuracy of your measurements.</p>

<p>To cope with this, I wrote my own <a href="https://github.com/ifreecarve/arduino_ci" rel="nofollow noreferrer">unit testing framework for Arduino</a>, which lets you fully mock (simulate) the hardware so that you can verify the operation of the software.  </p>

<p>There are some <a href="https://github.com/ifreecarve/arduino_ci#using-godmode" rel="nofollow noreferrer">examples of how my library accomplishes that, in the project README</a>.  Here is one for pins:</p>

<pre><code>unittest(pin_history)
{
  GodmodeState* state = GODMODE();
  int myPin = 3;
  state-&gt;reset();            // pin will start LOW
  digitalWrite(myPin, HIGH);
  digitalWrite(myPin, LOW);
  digitalWrite(myPin, LOW);
  digitalWrite(myPin, HIGH);
  digitalWrite(myPin, HIGH);

  assertEqual(6, state-&gt;digitalPin[1].size());
  bool expected[6] = {LOW, HIGH, LOW, LOW, HIGH, HIGH};
  bool actual[6];

  // convert pin history to an array, and verify expected results
  int numMoved = state-&gt;digitalPin[myPin].toArray(actual, 6);
  assertEqual(6, numMoved);

  // verify each element
  for (int i = 0; i &lt; 6; ++i) {
    assertEqual(expected[i], actual[i]);
  }
}
</code></pre>

<p>You may also like <a href="https://github.com/ifreecarve/arduino_ci#serial-data" rel="nofollow noreferrer">the example for mocking Serial port data</a>, although I probably need to improve that documentation.</p>

<p>The beauty of all this is that I was able to develop this framework and all these tests without ever plugging an Arduino board into my computer. </p>
