View Single Post
  #6   Spotlight this post!  
Unread 14-01-2013, 13:43
Chris Hibner's Avatar Unsung FIRST Hero
Chris Hibner Chris Hibner is offline
Eschewing Obfuscation Since 1990
AKA: Lars Kamen's Roadie
FRC #0051 (Wings of Fire)
Team Role: Engineer
 
Join Date: May 2001
Rookie Year: 1997
Location: Canton, MI
Posts: 1,488
Chris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond reputeChris Hibner has a reputation beyond repute
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:
void periodic_10ms_task(void)
{
    armAngle = WPI_readEncoder(ARM_ENCODER);
    armLimit = WPI_readDIO(ARM_LIMIT_SWITCH);

    armOutput = controlArm(armAngle, armLimit);

    WPI_setPWM(armOutput);
}
Before anyone complains: I don't really know what the WPI library function name are - the above names are made up (we use LabVIEW).

Now you can test you controlArm() function as a unit on a PC using MS VisualC++ Express.
__________________
-
An ounce of perception is worth a pound of obscure.
Reply With Quote