我希望能够单元测试我的Arduino代码。理想情况下,我可以运行任何测试,而无需将代码上传到Arduino。哪些工具或库可以帮助我做到这一点?
目前正在开发的Arduino模拟器可能很有用,但似乎还没有准备好使用。
Atmel的AVR Studio包含一个芯片模拟器,可能很有用,但我不知道如何将它与Arduino IDE结合使用。
我希望能够单元测试我的Arduino代码。理想情况下,我可以运行任何测试,而无需将代码上传到Arduino。哪些工具或库可以帮助我做到这一点?
目前正在开发的Arduino模拟器可能很有用,但似乎还没有准备好使用。
Atmel的AVR Studio包含一个芯片模拟器,可能很有用,但我不知道如何将它与Arduino IDE结合使用。
当前回答
试试Autodesk电路模拟器。它允许用许多其他硬件组件测试Arduino代码和电路。
其他回答
我不知道有什么平台可以测试Arduino代码。
但是,有一个Fritzing平台,你可以用它来建模硬件,然后导出PCB图等。
检查的价值。
该程序允许自动运行几个Arduino单元测试。测试过程在PC上启动,但测试在实际的Arduino硬件上运行。一组单元测试通常用于测试一个Arduino库。 (这
Arduino论坛:http://arduino.cc/forum/index.php?topic=140027.0
GitHub项目页面:http://jeroendoggen.github.com/Arduino-TestSuite
Python包索引中的页面:http://pypi.python.org/pypi/arduino_testsuite
单元测试是用“Arduino单元测试库”编写的:http://code.google.com/p/arduinounit
对每组单元测试执行以下步骤:
Read the config file to find out which tests to run The script compiles and uploads an Arduino sketch that contains the unit testing code. The unit tests are run on the Arduino board. The results of the test are printed over the serial port and analyzed by the Python script. The script starts the next test, repeating the above steps for all test that are requested in the configuration file. The script prints a summary showing an overview of all the failed/passed tests in the complete testsuite.
看起来乳香就能完美地完成这项工作。
Emulino是Greg Hewgill为Arduino平台开发的模拟器。(源)
GitHub库
你可以使用仿真——你可以在图表上拖放微控制器,然后在Eclipse中运行你的代码。网站上的文档会告诉你如何设置。
如果你想在MCU之外(在桌面上)进行单元测试,请检查libcheck: https://libcheck.github.io/check/
我用它测试了几次我自己的嵌入式代码。这是一个非常健壮的框架。