Why do I need JsTester when JsUnit is available ?

It all depends on your testing needs. JsUnit is an implementation of JUnit in javascript, and as such it is a tool to verify javascript code with more javascript code (nothing wrong with that). JsTester was born on the need to verify javascript code outbound from the server to a client. In this way, and integration test can verify the code before the actual client does the interpreting and possible crashes.


How do I use JsTester with JUnit 4.x ?

Follow the instructions on HowTo:Testing using JsTester. Don't forget to call onSetup() inside a method marked with @Before and onTearDown() inside a method marked with @After.

Remember that you must use the jdk15 version and that you only need junit4.jar on the classpath.


How do I use JsTester with TestNG ?

Follow the instructions as with JUnit4, but use TestNG's annotations instead.

You may use any version (jdk14 or jdk15) and you only need testng.jar in your classpath.


How do I use JsTester with Groovy ?

Extend GroovyJsTestCase, that's all =)

You may use any version (jdk14 or jdk15) and you need junit.jar in your classpath.

Here is an example using GStrings with variable interpolation:

import net.sf.jstester.ext.GroovyJsTestCase

class GroovyJsTesCaseTest extends GroovyJsTestCase {
   void testScript(){
     def groovyVar = "10";

     def script = """
        var counter = 0;
        function count(){

        for( i = 0; i < $groovyVar; i++ ){
     eval( script );
     assertExpressionEquals( "$groovyVar", "counter" );


Why doesn't JsTester support an assertion for XYZ condition ?

The initial assert* methods reflect those available in JUnit's Assert (except assertSame), but JsTester has a built-in feature to invoke your own validations: assertUnaryPredicate() and assertBinaryPredicate().