Unit-Tests via mUnit

Nearly a year ago I started to experiment with 3D in Haxe targeting Flash/AS3. I had no prior experience with it and I also had no idea how complicated and terrible interrelated a rendering engine can be. I downloaded all kinds of Engines and tried to reverse engineer their approach and supplemented it with a book about real time rendering. At the end I managed to render a static model with one direct light and a virtual camera. (the link works, it just takes forever)

Now a year later I'm trying to refactor the whole mess. I already had a GitHub project and forked it for the refactoring but somehow managed to lose it. or well ... fuck the repository up so much that it felt easier to just create a new one and used the opportunity to try a few new things out:
  • Build automation via Jenkins
  • Unit-Tests  via mUnit
I somewhat covered Jenkins so I'll say a bit about my mUnit discoveries. The framework was easy to install and get running, even setting it up to create the jUnit xml files Jenkins requires to output neat looking test graphs worked without many issues.  

A nice feature about mUnit is that you can start it via command line, which starts a neko server in the background and tests your compiled project in the browser and presents to you a neat looking test-result for every target you've chosen to test. (the server is also the reason why jUnit xml files can be created)

Sounds really cool but it turns out that you cannot test your AS project with a local projector as you normally would test your application while developing. So you won't get any stacks and you have no way to jump around in your code using breakpoints.

Compiling and starting the test locally in a projector greets you with run time errors regarding missing ExternalInterfaces that would be provided with the neat looking browser site the test is usually embedded in.

I would have loved to switch to the default haxe.unit tools but can't bring myself to write a system that would support exporting jUnit xml files. I already took a quick look into neko and created a little test server. It is a lot of fun and I would love to do it - but for now the debugging pain is not big enough as I can easily bypass the whole Unit-Test framework and just test the class by hand the old fashioned way.

To get back to my introduction about 3D. I tested the whole unit test shenanigans here using the mesh related data structures. So far it costs me quite a bit more time to write a test than I'd like to admit and I have my doubts how much it is worth at this point in development.

I always hear people say that you can't start early enough with it and I can see why they say it - but especially since I'm alone and still on a really massive refactoring heavy point of production I can't see how much it will help me. I can even imagine how painful updating the tests will be besides writing good ones in the first place. They don't cover much so far and are probably more complicated / error prone than they should be.

No comments:

Post a Comment