Whether you’re working with an existing application, or you’re planning a new app, unit testing provides an efficient, dependable way to verify that your code functions as expected and ensure that your app’s features work. In a nutshell, unit testing provides an automated way to target, test and validate specific components of an application.
window.dojoUrl = "http://serverapi.arcgisonline.com/jsapi/arcgis/?v=2.8";
By default, test modules are specified via a query string parameter called testModule. In the example linked above, the tests.all module is specified. That module rolls up tests from a couple of other modules that contain unit tests. By using modules, DOH allows you to run any number of tests, in any number of modules easily. For instance, to run only the tests in tests.TestModule1, specify that module as the testModule query string parameter. To see the specifics of how the various unit tests are implemented, please download the code from the link above.
Is this more work? Yes. Is it worth the trouble? Absolutely. While writing tests adds to the work required for app development, seeing tests run and pass instills confidence in your application that would otherwise be missing. By writing unit tests for your code, you can be sure that your app’s features and functionality work as expected. When tests are run throughout the development process, you know exactly how changes affect existing code and when things break. Unit tests do not completely replace manual, in-browser testing but they can go a long way to eliminating the majority of that work.