![]() |
Unit Tests & Test-Driven Development
Does anyone know of a sane way to write unit tests for robot code? I'd prefer to have a test-driven development cycle for our code, but I can't think of a good way to implement it for this kind of programming. There's a test harness project on FirstForge here, but it seems to be a dead project. Any ideas?
|
Re: Unit Tests & Test-Driven Development
Revive the project ;)
|
Re: Unit Tests & Test-Driven Development
Curious if short of emulating the robot like the test-harness project was trying for, does anyone have a nice flow for unit testing bits of logic sans crio that have no robot dependencies?
|
Re: Unit Tests & Test-Driven Development
I'd love to revive the project, but I don't think it's appropriate to do during build season.
|
Re: Unit Tests & Test-Driven Development
What we created for RobotPy users (python interpreter for cRio) is a library called fake-wpilib, which has bare implementations of most of the WPILib objects. You setup some hooks, import the robot code, and call StartCompetition(), and your unit tests have access to see/control everything.
We have implemented separately a tk-based program that allows our students to run their python robot code in a simulator of sorts, and they can drive the robot around and use sensors and such. If I was re-implementing the test harness again for C++, this is probably how I would go about it. It seems like someone could create a script that could parse the C++ code and automatically create functional shells from that. Tools like SWIG and SIP sorta do that sort of thing, you would just need a mechanism to map function inputs to public variables. |
Re: Unit Tests & Test-Driven Development
The simplest way is to design your software units for test. What I mean is this: do NOT make any calls to the WPI library from within your unit. Make all calls to WPI library in a wrapper function.
For example: Code:
Now you can test you controlArm() function as a unit on a PC using MS VisualC++ Express. |
| All times are GMT -5. The time now is 18:23. |
Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
Copyright © Chief Delphi