Free Trial

Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.


  • Create BookmarkCreate Bookmark
  • Create Note or TagCreate Note or Tag
  • DownloadDownload
  • PrintPrint
Share this Page URL
Help

Chapter 13. Ajax testing > JavaScript testing

13.4. JavaScript testing

Here, you face the same choice you had between HtmlUnit and Selenium: do you want to emulate a browser or drive a live browser? We look next at two JavaScript testing frameworks, RhinoUnit and JsUnit. RhinoUnit is like HtmlUnit, a 100 percent Java solution, and JsUnit is akin to Selenium in that it drives local or remote web browsers. To wrap up JavaScript testing, we use JSLint to check our code against best practices.

13.4.1. JavaScript testing with RhinoUnit

RhinoUnit allows you to run JavaScript unit tests from Ant. You write unit tests in JavaScript and invoke them from Ant with the help of the Java Scripting Framework and the Mozilla Rhino JavaScript engine included in Java 6. If you’re on an older version of Java, you’ll need the Apache Bean Scripting Framework[10] (BSF) and the Mozilla Rhino JavaScript engine as documented in appendix E, “Installing software.” As a bonus, RhinoUnit includes JSLint,[11] which allows you to check from Ant that your JavaScript code follows best practices. Download and unzip RhinoUnit.[12] If you’re on Java 6, you’ve finished; if not, some additional steps are documented in appendix E.

[10] http://jakarta.apache.org/bsf/

[11] http://www.JSLint.com/

[12] http://code.google.com/p/rhinounit/


  

You are currently reading a PREVIEW of this book.

                                                                                        

Get instant access to over
$1 million worth of books and videos.

  

Start a Free Trial