I would to write unit tests for a useful but not exactly thoroughly
tested Firefox extension called "BetterPrivacy". It consists of one
javascript file with one variable inside which there are functions.
Following the excellent examples [2] by Stephen Walther, but I can
access neither the var nor the functions inside it ("objbp is
undefined").  Please advice on how to access the variable objbp and
its contents.

The code in brief:

// The code to test (bp.js)
var objbp = {
        lsos: [],
        count: 0,

        GetBaseDir: function(platform)
        {
          // ... return user's home dir
        },
}

// The test code (bpTest.js)
function bpTest()
{
        this.testGetBaseDir = function()
        {
                // with "Break on all errors" enables,
                // execution stops on line below: "objbp is undefined"
                var basedir = objbp.GetBaseDir("linux");
                fireunit.ok(basedir == "/home/foo", "test home dir on linux");
        }
}

// The test web page (bpTest.html)
    // Non-script part excluded..
    <script src="bp.js" type="text/javascript"></script>
    <script src="bpTest.js" type="text/javascript"></script>

    <script type="text/javascript">

        var bpTest = new bpTest();

        // Run all tests in bpTest
        var method;
        for (method in bpTest) {
            if (method.substring(0, 4) == 'test')
                bpTest[method]();
        }

        // Display result summary
        fireunit.testDone();
    </script>



[1] https://addons.mozilla.org/en-US/firefox/addon/6623
[2] 
http://stephenwalther.com/blog/archive/2009/05/18/unit-testing-javascript-with-fireunit.aspx

Env: FF 3.0.13 on ubuntu 9.04, Firebug 1.4.2, FireUnit 1.0a2.

Thanks.
--


--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Firebug" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/firebug?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to