Dienstag, 4. Juni 2013

How to test NXT - Lejos (Java) in Eclipse

NXTs are a lot of fun to "play" with. But as the development of the software-side goes on it becomes harder and harder to find and fix bugs as they appear. As a good programmer it would only be logical to strife for a good coverage with unit-tests. But unfortunately the lejos development kit seems to only partially support JDK functionality thus rendering JUnit or any kind of mock-frameworks unusable.

So here is a little something to circumvent these restrictions:

1) Create a new Java-Project where your tests will be located
2) right-click on it and go into "Build Path" -> "Configure Build Path..."

3) select the "Project"-Tab and click on "Add" proceed by selecting the Lejos project you want to test.

Now you can proceed to write tests using your favorite Frameworks as if you were writing them in the lejos project itself.