Introduction to DOH Framework
As a rich, highly modular JavaScript library, Dojo is destined to require a large number of unit tests to ensure the stability of each functional module. The Dojo self-contained unit Test Framework DOH (Dojo Objective Harness) provides a solid foundation for writing various unit tests. Developers can use the DOH framework to quickly write the following unit tests:
Common Javascript Unit Tests
Asynchronous Javascript Unit tests
Javascript Performance Test
Web UI Interaction Test
By DOH Common JavaScript unit tests, you can ensure that synchronization JavaScript code logic is correct. DOH Asynchronous JavaScript unit tests can guarantee the quality of modules that contain asynchronous JavaScript code such as XHR calls, SetTimeout, setinterval, and so on. DOH provides performance unit testing that allows developers to easily build Benchmark for their own code. DOH Web UI Interactive testing uses a robot (robot) analog page interaction to automate UI interaction testing, making it no longer necessary for developers to test the UI of a page through repetitive manual actions.
The main code for the DOH test framework is in the util package of Dojo. The main features are provided by the following files:
Runner.js:DOH Core code, defines the base API for supporting DOH test framework
Util/doh/_browserrunner.js: Provides the ability to execute in the browser for the DOH test framework.
Util/doh/_noderunner.js: Provides the ability to use Nodejs execution for the DOH test framework
Util/doh/_rhinorunner.js: Provides the ability to use Rhino execution for the DOH test framework.
Util/doh/robot.js: Defines a robot (robot) API designed for Web UI interaction testing.
Util/doh/robot: This folder contains Java code and related resources to implement the robot interaction function.
Util/doh/plugins: This folder contains various plug-ins for the DOH. User-developed DOH Plug-ins can also be placed under this folder.
DOH testing can be done in a browser or a non-browser environment. In a browser environment, the DOH Framework provides a powerful UI interface that enables developers to visually differentiate DOH test case execution, suspend/execute specified test cases, view test reports, and so on.
Figure 1. DOH Test Interface
In a non-browser environment, when using Nodejs,rhino, pure JavaScript logic tests that do not involve UI interfaces and DOM or BOM are often used. DOH robot is not available in a non-browser environment.