本文介绍了我怎么能单元测试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的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-现有的单元测试框架,我创建的。这里有一个简单的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?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!