Unit testing is the testing of individual software components or modules. Unit testing is different from traditional testing because it is performed by the developer and not a tester; this is due to the fact that knowledge of the code is required for unit testing. Later, traditional testing is accomplished with all modules (that have been individually unit tested) working together.
A key feature of unit testing is assertions; these allow the developer to check code execution and variable and object state during unit testing. Assertions allow you to perform common comparisons and condition testing to examine how code is running.
JUnit is a popular unit-testing tool for Java code. It was developed years ago, and it has become one of the more popular unit testing frameworks for Java developers. JUnit is based on the xUnit framework, which is a set of language-independent concepts and constructs for writing and running unit tests.
- Internet Explorer 5.5+ on Windows 95/NT/2000/XP and Mac OS 9/X
- Mozilla 0.9.4+ on all platforms
- Firefox 0.9+ on all platforms
- Netscape 6.2.3+ on all platforms
- Konqueror 5+ on Linux KDE 3.0.1+
- Safari 1.2+ on Max OS X
While JsUnit provides the same functionality as JUnit and NUnit, it utilizes its own vocabulary to describe its features. For example, JsUnit’s unit tests are called Test Functions, which reside in Test Pages (an HTML file). A test runner page is used to run Test Pages.
JsUnit is a great tool; however, it has been a couple of years since there were product updates on its SourceForge page.
Tests are defined in a test file that sets up the tests to run, as well as other functions. It allows you to set up various elements of a test (such as HTML elements) and user actions (like clicking a button) to simulate user interaction. The output of using Crosscheck is a bit rudimentary, as it is generated via the command-line interface.
The Dojo Toolkit also provides a robust unit testing environment. Its testing tool is called the Dojo Objective Harness; it facilitates the use of custom namespaces but requires special steps to utilize the test runner included within the Dojo Toolkit. Dustin Machi’s SitePen blog post provides instructions for making the Dojo Objective Harness work.
What tools do you use?
In Web development, there is a constant state of flux as tools and techniques continue to evolve and be introduced. What tools do you use to implement unit testing or other chores in your everyday work? Share your experiences and recommendations with the Web Developer community.
Tony Patton began his professional career as an application developer earning Java, VB, Lotus, and XML certifications to bolster his knowledge.
Get weekly development tips in your inbox
Keep your developer skills sharp by signing up for TechRepublic’s free Web Developer newsletter, delivered each Tuesday. Automatically subscribe today!