Mastering Web Application

(Rick Simeone) #1

Building and Testing


With modern tools it is possible to have extremely efficient setup. For example, here
is the screenshot of the development environment used to write examples for this
book. As you can see the source and test code are opened side by side so it is easy
to switch between writing test and production code. Karma runner is watching the
file system to execute test on every file save operation and provide the immediate
feedback (in the lower pane):


Unit testing environment described here is in fact the lightest possible
development environment. We can work all the time in our IDE and
focus on writing code. No need to switch context for building, deploying
or clicking in a browser to verify that our code works as expected.

Karma runner tips and tricks

Practicing Test Driven Development (TDD) greatly reduces number of long debugging
sessions. When writing code test, first we are usually doing small changes and running
tests often so the change that causes test to fail is just few keystrokes away. But despite
our best efforts there will be times when we won't be able to understand what is going
on without resorting to a debugger. In times like those we need to be able to quickly
isolate a failing test and focus on this one test.

Free download pdf