I was working on some Javascript today, and in the middle of working on the script I thought, “Man, it would be nice if I had a quick, easy unit testing environment to test stuff out as I write this”. Then it hit me – I do.
I forgot I wrote this simple unit testing framework back in 2006. It was part of Neuromancer (one of those old school Ajax libraries), and I had always planned on release it as it’s own thing, but I never really did.
Here is a short movie on how it works:
The positive reasons for using this are 1) the interactive shell 2) the fact it works from the desktop and off a live server and 3) you can run it in different browsers so you can test in IE / FF / Safari rather easily (as opposed to unit testers that just work in FF or within a JRE).
I use this, and unit testing in general, as a way to easily develop parts of a system in isolation – instead of running the code through the whole server / process. An added side effect is the unit test. However, I find the ability to run small parts of the code more beneficial than “writing test cases” (which in the end is the same thing I guess). But that’s why I call it more of a Playing Around Area than a Unit tester.
You can download the code from the JUTest project page.
Nice stuff, Rob! Hey, how does this compare with jsunit?
best,
bill
JSUnit looks to be a more like a traditional unit testing process. The single unit of something looks like it’s an HTML file in JSUnit. Whereas JUTest is more of a js focused include test.
This is designed more around a harness idea with unit testing as a nice addition. It also looks to be a bit easier to print out the tests with JUTest – if that is something you care about.
To save large groups of test JSUnit looks nice. Meaning if you have 6 projects and you wanted to keep unit tests on each project then JSUnit, because it includes HTML files for the test, would just use the one run time for all projects. With JUTest you’d have to write different index.html files for each project, so could possibly be a little disjointed.
JSUnit has startUp and tearDown JUTest doesn’t (but JUTests runs you methods in order so that doesn’t really matter)
They are quite similar. I think maybe the shell, and printing are what set them apart. For a quick sentence separation “IMO, JSUnit was written specifically to emulate a traditional unit testing framework, JUTest was written as a test harness / environment with aspects of traditional Unit testing”
I haven’t actually used JSUnit mind you…