我怎么能单元测试Arduino的code? [英] How can I unit test Arduino code?
问题描述
我希望能够单元测试我Arduino的code。理想情况下,我将能够无需上传code到Arduino运行任何测试。什么工具或库可以帮助我?
I'd like to be able to unit test my Arduino code. Ideally, I would be able to run any tests without having to upload the code to the Arduino. What tools or libraries can help me with this?
有正处于发展的一个 Arduino的仿真器可以是有用的,但它尚未似乎是准备使用。
There is an Arduino emulator in development which could be useful, but it doesn't yet seem to be ready for use.
AVR Studio的爱特梅尔中包含一个芯片模拟器这可能是有用的,但我不能看我怎么会用它与Arduino的IDE结合使用。
AVR Studio from Atmel contains a chip simulator which could be useful, but I can't see how I would use it in conjunction with the Arduino IDE.
推荐答案
在为没有任何Arduino的pre-现有的单元测试框架,我创建的 arduinoUnit 。这里有一个简单的Arduino草图展示了它的用法:
In the absence of any pre-existing unit test frameworks for Arduino, I have created ArduinoUnit. Here's a simple Arduino sketch demonstrating its use:
#include <ArduinoUnit.h>
// Create test suite
TestSuite suite;
void setup() {
Serial.begin(9600);
}
// Create a test called 'addition' in the test suite
test(addition) {
assertEquals(3, 1 + 2);
}
void loop() {
// Run test suite, printing results to the serial port
suite.run();
}
这篇关于我怎么能单元测试Arduino的code?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!