j3unit logo
J3Unit Overview

J3Unit is an object-oriented unit testing framework for JavaScript. J3Unit runs JavaScript tests directly in the web browser and can be automated using JUnit and Jetty. J3Unit builds on previous work by JSUnit and Script.aculo.us to provide a better way to automate JavaScript unit tests. Object-oriented JavaScript unit tests are written using the Script.aculo.us Test.Unit.Runner object, which is in turn built upon the prototype JavaScript library.

J3Unit has 3 modes of operation: Static Mode, Local Browser Mode, and Remote Browser Mode

Static Mode

Static mode allows the user to run the JavaScript tests directly without using JUnit or Jetty. Static mode is intended to help developers while they are working on writing JavaScript and JavaScript test cases. When the developer makes a change to a JavaScript file or unit test, all they need to do is reload the static page in their web browser to see the results. This provides immediate feedback to the developer and can allow them to follow a test-first development methodology. Static mode can also be used by people who just want to run the tests manually.

See a demo of static mode here

To use static mode, simply unzip the j3unit-X.X.X-static.zip file and load the included index.html in your browser.

Local Browser Mode

Local Browser Mode is a JUnit test case DefaultJ3UnitTest that runs both Jetty and Firefox on your local machine. This test case is intended to be included in a larger suite of JUnit tests that the user plans on running directly on his or her machine.

Settings for this test case should be included in a properties file called j3unit.properties. This file should be located somewhere on the Java class path.

To run the JUnit test(s), either execute them directly from the jar file or add them into another JUnit test suite. You must have a valid j3unit.properties file with proper settings for your system on the Java class path. A sample j3unit.properties file comes with the download below. Simply rename it to j3unit.properties and add it to you Java class path.

Remote Browser Mode

Remote Browser Mode is also a JUnit test case DefaultRemoteJ3UnitTest and works in the same way as Local Browser Mode except that the browser is run on a remote machine instead of the machine running the JUnit test. This is useful when running automated tests on a machine that may not have the ability to launch a browser itself, such as many Unix or Linux server configurations. This will allow the Unix or Linux machine to execute the JavaScript tests using a remote browser setup on another machine capable of running the browser directly.

J3Unit Status

J3Unit is currently in beta and is tested with Firefox 1.5 and Jetty 6.0.0 beta.

Download J3Unit

J3Unit can be downloaded from sourceforge.net.

SourceForge.net Logo