js-test-driver Phing task - Westhoffswelt - Welcome to the real world

js-test-driver Phing task

One of the projects I am currently developing is heavily javascript based. Therefore I needed a productively usable unit-testing framework for the javascript part of the application. As I am mainly developing in a terminal using vim, I wanted a solution which could run js tests from within a terminal shell.

js-test-driver is a javascript unit-testing framework which does meet all my criterias. To be able to productively use this framework I needed to integrate it into the application build-process, which is controlled and run by Phing. Therefore I wrote a really simple Phing task to run the js-test-driver runner from inside a Phing build file.

As I thought some of you might be in need of something like this, I decided to share this simple, but yet useful task.

Download

As the repository hosting the project this task has been developed for is not yet open to the public, I just uploaded the Phing task file, which can be downloaded below.

Usage example

The usage of the task is really simple. Just tell Phing where to find the newly task class and how the task is named. Then just use it supplying a js-test-driver jar file, the javascript sources to be included and the testfiles to be run.

A simple buildfile using the jstestdriver task does look like this:

<?xml version="1.0"?> <project name="some project" default="test" basedir="."> <taskdef name="jstestdriver" classname="phing.tasks.jsTestDriverTask"/> <target name="test"> <jstestdriver jar="tests/runner/JsTestDriver-svn-324-patched.jar"> <fileset dir="build"> <include name="build.js" /> </fileset> <fileset dir="tests"> <include name="this/*.js" /> <include name="that/*.js" /> <include name="something_else/*.js" /> </fileset> </jstestdriver> </target> </project>

Want to learn more about js-test-driver?

I will be giving a talk about js-test-driver itself on Friday, 06. November at the PHP Usergroup CGN. Attendance is free and you are welcome to join us.

Trackbacks

Comments

Add new comment

Fields with bold names are mandatory.