SoftwareTesting:Tools:jsUnit
Jump to navigation
Jump to search
- example jsunit-based tests (davel's examples)
- urls in test suite pages are resolved relative to the url of the test runner page, not the url of the test suite page
- can we use chrome urls (with appropriate manifest files) to access the jsunit core js files in a path-independent manner? this means we just have to worry about the test runner page and the test suite/case pages.
- this is only a problem for packaging jsunit-based tests in our tree so that they point to the same core jsunit files
Description
jsUnit is a fairly mature harness for in-browser testing. We can easily use it to run tests that can run as content
How to run the test
- download jsunit from jsunit.net
- I've had success playing with 2.2a11
- unzip the file
- I didn't do any of the installation stuff for jsUnit Server - I just used the unpacked files as-is
- add your test to the jsunit directory (the one containing testRunner.html)
- load testRunner.html in your browser
- use the file picker to select the test you just wrote
- run the test
Example
dom_3348.html: tagName of HTML element should give tag in upper case (bug 3348)
<HTML> <HEAD> <script language="javascript" src="app/jsUnitCore.js"></script> <script> function test3348() { var oForm = document.getElementById("form1"); assertEquals("FORM", oForm.tagName); } </script> </HEAD> <BODY> <form id="form1"> <input type="button" value="click here" onclick="buttonClick();"> </form> </BODY> </HTML>
Output
the test passes
Comments
- jsUnit also supports test suites.
- paths for files in addTestPage() are evaluated relative to the testRunner page, not the test suite page