HTML and CSS Reference
In-Depth Information
Test to Learn
I n the previous three chapters we have seen how automated tests can help improve
quality of code, guide design and drive development. In this chapter we will use
automated tests to learn. As small executable code examples, unit tests make a
perfect learning resource. Isolating a specific aspect of an interface in a unit test is a
great way to learn more about how it behaves. Other types of automated tests can
help our understanding of both the language and specific problems. Benchmarks
are a valuable tool to measure relative performance, and can guide decisions about
how to solve a specific problem.
4.1 Exploring JavaScript with Unit Tests
Quickly executing JavaScript, as in executing a few lines of script to explore the
behavior of some object, is fairly simple. Most modern browsers ship with a console
that serves this purpose just fine. Additionally, there are several options for JavaScript
command line interfaces when the browser environment is not of particular interest.
Although this sort of one-off coding session can help our understanding of an inter-
face, it suffers from the same problems that manual application testing does. There
is no way to repeat a given experiment, there is no record of previously run experi-
ments, and there is no simple way of repeating an experiment in multiple browsers.
In Chapter 1, Automated Testing, we introduced unit tests as a means to solve
the problems brought on by manual testing. Surely, unit tests can help us solve
Search WWH ::

Custom Search