Mastering Web Application

(Rick Simeone) #1
Chapter 2


  • The syntax used by the Scenario Runner makes it really easy to find DOM
    elements, interact with them, and assert on their properties. There is a
    complete domain-specific language (DSL) for searching and matching
    repeaters, inputs, and so on.


Unfortunately, as the time was passing by more and more limitations of the Scenario
Runner were surfacing. Due to this, as of time of this writing, the Scenario Runner
is not actively maintained. There are plans to replace it with another solution based
on Selenium integration, namely, Protractor. The work in progress can be seen in the
GitHub repository at https://github.com/angular/protractor.


We recommend against using the existing Scenario Runner for any
new project. It is not actively maintained and it won't evolve. Instead,
you should keep an eye on Protractor.

Daily workflow

In order to be effective, automated testing needs to be applied rigorously. Tests
should be run as often as practicably possible and failing tests should be fixed as
soon as possible. A failing test should be treated as a failing build, and fixing a
broken build should be a top priority for a team.


During the day we will be switching, back and forth between JavaScript code and UI
templates. When focusing on the pure JavaScript code and other AngularJS artifacts
(such as filters or directives), it is important to run unit tests often. In fact, due to
the remarkable speed at which AngularJS test can be executed with the Karma test
runner it becomes practical to run all the unit tests as often as on every file save!


While writing the sample SCRUM application, the authors of this book were
working with the Karma runner set up in a way that it would monitor all the file
changes (both to the source code and the test code). On each and every file save a
complete suite of tests were executed providing an immediate health-check. In such
a setup, the feedback loop becomes very short, and we can always know that either
our code still works as expected or was broken just seconds before. If things are in
order we can swiftly move on, but if tests start failing we know that it is due to one
of the latest changes. With the tests running so often, we can say goodbye to long
and tedious debugging sessions.


Running tests shouldn't require much effort. It is very important to have a comfortable
testing environment, where the automated test suite can be executed as often as
possible. If running a test involves several manual, tedious steps, we will avoid testing.

Free download pdf