How to Fly While Developing an Eclipse TDD Plugin

An Unexplained Mystery

ProblemHave you ever had a problem that you did not figure out until years later?  In 2013, I was developing a plugin for the Eclipse IDE that measured TDD-compliance for Python developers.  This was a project for my Master’s degree at Auburn University.  When I ran unit tests against my code, all the sudden an XKCD comic would launch in a web browser.  It almost seemed like there was a tiny little gnome hiding in my computer, laughing at me.

It really was comical.  Line after line of code… hours after hour of working on this project… and then a funny comic out of the blue every now and then.  The exact comic is the XKCD about Python’s antigravity: view it here.  The Python programmer imports an antigravity library and then starts flying.

It was not until a few days ago (4 years after that project) I better understood what was going on.  I’m still not 100% certain, but I at least have a better idea.

The Tools Being Used

Java

I was developing the Eclipse plugin in Java.  For those unfamiliar with TDD(test-driven development), it is a development process that has three steps:

 

  1. Don’t write source code first – write a failing unit test instead.
  2. Write only enough code to make that failing test pass.
  3. Refactor both the source and test code.

Those three steps are repeated until you have developed your feature.  At the end of your development, you already have a suite of tests that verify your code works.

This plugin used events in Eclipse (such as a file save event, and unit test run event, etc.) to determine the behavior of the developer.  I won’t go into the details during this post – that’s for a future post.  The Python XKCD comic popped up when I ran unit tests for my Java plugin code for Eclipse.

How Did It Happen?

The light-bulb moment happened a few days ago when I imported the antigravity library from the Python console.  Go ahead and try it!

Antigravity

Woah!  That code opened up a browser!  And what do you know… it has that same XKCD comic in it!

Apparently Python has an Easter Egg that opens up that web comic whenever the antigravity library is imported.  Now… I don’t necessarily recall importing that library.  I’m assuming somewhere in my TDD plugin code, it somehow triggered a Python import that imported that library.

Personally, all I knew at the time is that I was writing code to test TDD compliance with Python code.  It was interesting that a Python comic came up, since my project was related to Python code.  I even made a Facebook post at the time.  I thought I had gone crazy.  However, I never knew about this Easter Egg until a few days ago.  Then this ‘clever prank’ from several years ago made more sense.

XKCD Facebook Post

Conclusion

At the time, I never searched too hard to figure out why that was happening.  It’s interesting that several years, out of nowhere, I randomly happened to find this Easter Egg.

At any rate, developing this plugin was an interesting challenge.  Trying to measure TDD-compliance really made me think about what it means to correctly follow this development process.

  • How do you know when someone didn’t write a unit test first?
  • What about when too much code was written after the unit test?
  • How do you distinguish refactoring from developing new code?

These questions and how I answered them in my development will be addressed in a future post.

Have you run across silly Easter Eggs that completely confused you… maybe even for years?  I’d love to hear about your stories in the comments!

Leave a Reply

Your email address will not be published.