0

I'm just starting out with JsTestDriver and I've created very simple demo code to see if I have configured my environment correctly. However about 40-50% of the time I'm getting the following error when Firefox is launched (via JsTestDriver) "Firefox Closed Unexpectedly While Starting".

This error does not occur if I use Chrome.

My environment consists of:

  • VirtualBox 4.1.18 running Ubuntu 10.04.4 LTS 32bit
  • Firefox 13.0.1
  • JsTestDriver-1.3.4.b
  • openjdk-6-jre-headless

I'm executing:

java -jar /home/developer/bin/JsTestDriver.jar --port 9876 --browser /usr/bin/firefox --tests all --testOutput results

My JsTestDriver config is:

server: http://localhost:9876

load:
  - src/*.js

test:
  - test/*.js

timeout: 10

The source code (code under test) is:

Person = function()
{
    this.firstName = "";
    this.lastName = "";

    this.fullName = function()
    {
        if((this.firstName != "") && (this.lastName != ""))
        {
            return this.lastName + ", " + this.firstName;
        }

        var name = this.firstName + " " + this.lastName;
        return name.trim();
    }
};

The test code (JsTestDriver based code) is:

PersonTest = TestCase("PersonTest");

PersonTest.prototype.testFullName = function()
{
    fixture = new Person();
    fixture.firstName = "John";
    fixture.lastName = "Doe";

    assertEquals("Doe, John", fixture.fullName());
};

PersonTest.prototype.testFullName_FirstNameOnly = function()
{
    fixture = new Person();
    fixture.firstName = "John";

    assertEquals("John", fixture.fullName());
};

PersonTest.prototype.testFullName_LastNameOnly = function()
{
    fixture = new Person();
    fixture.lastName = "Doe"

    assertEquals("Doe", fixture.fullName());
};

Thanks!

Nick
  • 21
  • 5

1 Answers1

0

Your problem may be in that you're spinning up your server opening your browser every time you run your tests. I think a less error prone solution would be to start your server and have it capture some browsers, and then leave it running. Then you can run your tests against that server as needed. Our solution at work involves three virtual machines running IE7,IE8,IE9,Firefox, and Chrome all the time, and our Maven build process runs our javascript unit tests at every build. Also, make sure that you always use the '--reset' argument as well. It will keep your browsers fresh. I wrote a post that shows how to integrate QUnit, Requirejs, and code coverage with JSTD that is independent of Maven: js-test-driver+qunit+coverage+requirejs. Hope it helps.

jdobry
  • 1,041
  • 6
  • 17
  • great suggestion! Running the JsTestDriver server on its own improves the stability. However, on occasion I still see the crash when the server starts up (I'm autocapturing the browser). I feel that it has something to do with how Firefox is closed when the JsTestDriver server ends. Is there a proper way to close the server, right now I'm simply doing a ctrl+c. My guess is killing it this way doesn't allow Firefox to cleanup and close. – Nick Jul 01 '12 at 23:10
  • How is Firefox's stability when you start it manually from commandline/bash/shell? All JsTestDriver does is run Firefox's executable, so I suspect either your environment, Firefox installation, or combination thereof are unstable. I haven't tried this on a Linux box, but so far I haven't had any problems with Firefox on Windows. Also, you could try writing a script that starts Firefox and sends it to http:// your.server's.ip.address/capture instead of letting the server autocapture the browser on startup. – jdobry Jul 09 '12 at 17:29
  • Well you called it. Something is up with my environment. This time I created a very simple shell script that launches Firefox (as a background process), sleeps for 2 seconds, kills the process and repeats 10 times. On the second launch Firefox complains that it wasn't closed properly. After about the 4-5 launch it starts display a "safe mode" dialog prior to opening the browser. – Nick Jul 13 '12 at 05:45
  • As it turns out this is a known issue in Firefox... https://bugzilla.mozilla.org/show_bug.cgi?id=336193 – Nick Jul 13 '12 at 05:53