HTML and CSS Reference
In-Depth Information
Open calculator.html in Aptana Studio, if it isn't already. A unit test simply runs
several assertions that check to see whether the outcome value for a method or
property matches an expected value based on a predictable input. The
calculator example in this chapter is simple in that it's easy to predict that 1+1
should always equal 2. There are no additional variables that should affect the
expected outcome, so 2 should always be the expected result. When 2 isn't the
result, you know that the application is broken somewhere.
In calculator.html , create a new script tag just before the closing body tag.
<div id="qunit-fixture"><!-- If you have DOM that needs to be manipulated,
this is where it should go --></div>
<!-- This is your new script tag -->
Within the script tag, you can begin to write your first set of unit tests. Although
the calculator code hasn't been written yet, you can begin to dictate what
methods and properties should exist within the code, and how they should
behave through the unit tests. A basic calculator should do the following:
A calculator will usually take an initial value to perform these methods on and
should return a result on each method. You should also be able to clear the
calculator. On this basis, the following methods should be implemented:
You can then convert this description of the application into unit tests.
Search WWH ::

Custom Search