Here on team 246 Overclocked, we love to follow the best of engineering practices. For software, that means unit testing our code.
For those who are not familiar, unit testing is a way to check “Does this piece of code do what I expect it to do?”. The most basic atom (or shall I say “unit”) of a unit test is an assertion, usually of the form assertEquals(myFunction(input), myFunctionExpectedOutput). There are lots of resources online on the subject of unit testing, so I won’t go in depth here. What we’ve done is created a template for FRC teams to use JUnit in their projects.
Overclocked is excited to announce that we’ve set up an awesome way to unit test FRC Java code! Check out our template: https://github.com/246overclocked/frc-java-junit-template
Follow the instructions in the README to get started!
- Automatically run all tests on your computer using ant test
- Automatically compiles and runs tests with each push to GitHub using Travis CI
In the world where FRC programmers get little time with the robot in the already short build season, this helps programmers avoid the “oops” moments and silly avoidable mistakes before getting access to the robot.
Why this is awesome:
- Ensures your code compiles
- Lets you check your logic/math independent of the robot
On Overclocked we love JUnit + Travis CI because we have a large group of students, many of whom are novice programmers, contributing to the robot code. This setup helps us get rid of bugs before we run the code on the robot.
Bugs? Questions? Feature requests? Create an issue, post to this thread! Want to help? Pull requests are welcome!
Shoutout to our early adopters! Other teams who are are having trouble should check out these two issues as they may already answer your questions!
(Note: Overclocked has no affiliation with Travis CI)