Blog

Showing posts with label eclipse. Show all posts
Showing posts with label eclipse. Show all posts

Sunday, April 10, 2011

How to Integrate Jenkins monitoring into Eclipse

Install the Hudson/Jenkins Mylyn integrator to see build status in Eclipse.
  1. Add this update site to your Eclipse: http://download.eclipse.org/mylyn/releases/latest/ It's still in "incubation" so it seems it's not available in the regular download site yet.
  2. Under Mylyn Integrations, select and install "Mylyn Builds Connector: Hudson/Jenkins (Incubation)"
  3. Once it's finished installing, use Window > Show View > Other... to select the Mylyn Build window
  4. Select the blue cylinder representing "Add new build server" from the task bar.
  5. Enter the info for the Hudson/Jenkins server and voila!
It's pretty nifty, too. Not only do you see build results, but you can view test results in the regular Eclipse JUnit view, examine the build's console output, view the changes for that build – in short, see pretty much all you see in the regular Jenkins web UI, but laid out in better (?!) and integrated nicely with Eclipse. Recommended.

For more info, see the Mylyn site.

Friday, April 09, 2010

Class: Robot Programming with leJOS

I am teaching a class on robot programming with leJOS as a follow-up to my "Programming with Scratch" class. LeJOS is an embedded JVM for LEGO Mindstorms. I started with a 30 minute tutorial on Object Oriented programming (what's a class? what are instances, methods, inheritance and polymorphism?) Yes, 30 minutes.

Then we jumped straight into test-driven development with JUnit and my own library that sits on top of the leJOS API. (I had to make this layer because leJOS objects are untestable.) Predictably, this was challenging, but not impossible! However, since we're dealing with fake (testable) motors and light sensors and so on, the production code we write doesn't cause physical wheels to turn and so on. That makes this all very abstract. It's a healthy stretch for a 12 year old, but they're doing it.

We took 15 minutes out to begin assembling the robot, and wrapped up the session with a brief retrospective.

Next week we'll download some of our code and watch the robot move (assuming we can build the damned thing!) Then we'll continue test-driving more behavior.

This is cool!

Friday, March 26, 2010

Test-driven development with leJOS in Eclipse

I have a working setup and have been happily test-driving development of an embedded leJOS app all day!

I created one project for the app itself (CUT - code under test). It has only the leJOS classes.jar (and no JDK/JRE classes) and uses the Eclipse Java Builder as would a standard Java app.

I created a second project for the tests. It's a plain Java project. It has the CUT as a project dependency.

Now for the code that made this possible: For several of the classes (Motor, LightSensor, etc) I had to make special decorators so that I could mock them.

For example, I have an Eye class that has-a LightSensor and which implements setLightValue() in addition to the pass-through getLightValue(). In my tests, I have a TestableEye subclass of Eye that simply remembers the value passed in to setLightValue() but does not call the underlying LightSensor at all.

I did the same thing with Motor. There's a decorator with a "Testable" subclass.

Now my unit tests (when we teach this stuff, we use the term "microtest" because it's less confusing to the QA folks) I simply instantiate a robot with a bunch of TestableMotors and TestableEyes. The microtest then exercises all the hairy logic required to get data from the eyes and drive the motors.

This is a pretty strong proof of concept. I expect to build up a few of these decorators to work around the issues with the leJOS design philosophy, specifically that work is often done in the no-args contructor. That makes them extremely difficult to subclass for testing purposes (that is, to mock.)

Epilogue
I was told this in the leJOS forums:

Note, that on the NXT, only the classes in the file classes.jar are available, and that this contains only a limited subset of the JDK APIs. For example, reflection is not available. Ergo, JUnit will not work.

There's something about proving people wrong when they say "it cannot be done."

Wednesday, June 17, 2009

Eclipse Regular Expressions plugins

Whenever I need to use regular expressions in Java, I end up wasting time messing with them to get them to work. And because you have to write your regex as a String in Java, you have to escape all the backslashes. Pretty soon, it becomes really hard to read. What I would really like is a plugin that lets me test my regex dynamically.

Others have thought of this. So I installed a variety of them and tried them out.

First up, Eclipse Regular Expression Tester. Its update site is http://brosinski.com/regex/update After installing, it shows itself in the preferences as RegEx Tester. It provides a new view called RegEx Tester. After a little testing, it seems that it does its job. The view makes very inefficient use of screen real estate. The results of the "test" occupy too much vertical space.

I also did not like the way you have to configure regex parameters globally. When I'm doing regex stuff, it's different every time. I need to be able to tweak in a more immediate way.

Next is QuickREx. The update site is http://www.bastian-bergerhoff.com/eclipse/features

This one does a variety of flavors of regex (JDK, ORO, blah, blah, with Perl and awk varieties) fwiw. You can also keep the regex's and "test text" in a library.

This thing is even worse with screen real estate, but at least the options are available in the view so you don't have to go to the prefs to change them. There's also a dialog for constructing a regex by selecting components from dropdowns. This seems a little odd to me, since if you know the meanings of all the terms in the dropdowns, you almost certainly know a shitload about regex and you don't need this tool. Whatever.

Anyway, it's the winner so far, even though the "copy regex to Java String" button doesn't work.

On to Regex Util. Update site is http://regex-util.sourceforge.net/update/ This is all about Java-style regex's, so maybe less UI clutter? Anyway, this one has no prefs. The UI is nicely laid out: minimal. Options and flags are dropdowns, not a gazillion checkboxes. Unlike the others, this one does not show groups, but it does highlight the match as you select parts of the regex. This seems like a cool debugging tool. Besides, once can always go into "replace" mode and enter the requisite $1, $2 and so on.

And copying to a Java-style String works and the opposite function is available.

Yay! This one is the winner.

Twitter Updates

Facebook

Blog Archive