jsTestDriver and Eclipse Indigo: Test Driver Configuration file how to

Here’s how to set up a simple test case for testing JavaScript complete with configuration file jsTestDriver.conf using jsTestDriver from Google and the Eclipse plugin.

1. Install the software as described on the page

2. Read the instructions on that page!!!  They tell you things that you have to do first, like

  • point to the location (set the path) of your browser’s executable file
  • open an Eclipse view which shows nifty start buttons, browser icons, and progress

3. Once you set those two things, you are ready to create a very short file that looks something like this (this is a terrible example for a real development environment, but it will get you started).  Note my project contains a folder called WebContent directly below the project name.  If you are using the Java EE version of Eclipse, your folders are probably different, so adjust this file as necessary:  My file will be WebContent/jsTestDriver.conf

Here it is:

– WebContent/*.js

Now I created a phony test case.  Normally you would have a javascript file for the test case, and another for the actual code, but I’ll keep it simple here: I’ll create a test case that doesn’t require any code:

Here is WebContent/a-test.js

TestCase(“strftimeTest”, {
    setUp : function() {
        date = new Date(2009, 9, 2, 22, 14, 45);
    tearDown : function() {
        delete this.date;
    “test %Y should return full year” : function() {
        var year = date.getFullYear(this.date);
        assertEquals(2012, year);
    “test %m should return month” : function() {
        var month = date.getMonth(this.date);
        assertEquals(9, month);

That is all!  (btw there’s an intentional error in this code so you should get one test failing, and one succeeding 😉

(Need more info?  http://meri-stuff.blogspot.com/2012/01/javascript-testing-with-jstestdriver.html)


About SunKing2

Former web developer, guitar player, started Piano 2012 -yes still doing it! Recovery, sobriety, mental health advocate.
This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s