JavaScript:SpiderMonkey:JS Tests: Difference between revisions

From MozillaWiki
Jump to navigation Jump to search
(Compiled by crowder from an IRC convo with bclary)
 
m (Couple more rules)
Line 3: Line 3:




*  Use reportCompare() to report success/failure!
*  Use reportCompare() to report success/failure! (except for e4x cases)
*  If your test will always throw an uncaught exception then you should name it with a suffix -n; it is always preferable to catch and handle exceptions directly.
*  If your test will always throw an uncaught exception then you should name it with a suffix -n; it is always preferable to catch and handle exceptions directly.
*  Don't use print(), use printStatus() or writeLineToLog(), etc.
*  Don't use print(), use printStatus() or writeLineToLog(), etc.
*  The tests will also be run in the browser in addition to the shell.  If you use shell only features, detect that and let the browser report success.
*  The tests will also be run in the browser in addition to the shell.  If you use shell only features, detect that and let the browser report success.
*  Do the converse, if you have a browser-only test.
*  Do the converse, if you have a browser-only test.
*  Each sub-suite has its own style -- use the template.js in that sub-suite's directory to as a starting-point for new tests.
*  Each new sub-suite directory must have an empty shell.js and browser.js
When in doubt about this, ask for help.

Revision as of 05:37, 31 August 2006

Rules for Writing JavaScript Test Cases

  • Use reportCompare() to report success/failure! (except for e4x cases)
  • If your test will always throw an uncaught exception then you should name it with a suffix -n; it is always preferable to catch and handle exceptions directly.
  • Don't use print(), use printStatus() or writeLineToLog(), etc.
  • The tests will also be run in the browser in addition to the shell. If you use shell only features, detect that and let the browser report success.
  • Do the converse, if you have a browser-only test.
  • Each sub-suite has its own style -- use the template.js in that sub-suite's directory to as a starting-point for new tests.
  • Each new sub-suite directory must have an empty shell.js and browser.js

When in doubt about this, ask for help.