Chapter 1
[ 9 ]
Enter the automation era
Test automation has been around for some years, even before the Web was around.
As soon as graphical user interfaces (GUIs) started to become mainstream, the
tools that allowed you to record, build, and run automated tests against a GUI
started appearing. Since there were many languages and GUI libraries for building
applications, many tools that covered some of these started showing up. Generally
they allowed you to record a testing session that you could later recreate automatically.
In this session, you could automate the pointer to click on things (buttons, checkboxes,
places on a window, and so on), select values (from a select
box, for instance), and input keyboard actions and test the results.
All of these tools were fairly complex to operate and, worst of all, most of them
were technology-specic.
But, if you're building a web-based application that uses HTML and JavaScript, you
have better alternatives. The most well known of these is likely to be Selenium, which
allows you to record, change, and run testing scripts against all the major browsers.
You can run tests using Selenium, but you need at least one browser for Selenium to
attach itself to, in order to load and run the tests. If you run the tests with as many
browsers as you possibly can, you will be able to guarantee that your application
behaves correctly across all of them. But since Selenium plugs into a browser and
commands it, running all the tests for a considerably complex application in as many
browsers as possible can take some time, and the last thing you want is to not run the
tests as often as possible.
Unit tests versus integration tests
Generally you can divide automated tests into two categories, namely unit tests
and integration tests.
• Unit tests: These tests are where you select a small subset of your
application—such as a class or a specic object—and test the interface the
class or object provides to the rest of the application. In this way, you can
isolate a specic component and make sure it behaves as expected so that
other components in the application can use it safely.
• Integration tests: These tests are where individual components are combined
together and tested as a working group. During these tests, you interact
and manipulate the user interface that in turn interacts with the underlying
blocks of your application. The kind of testing you do with Zombie.js falls in
this category.
www.it-ebooks.info