HTML and CSS Reference
In-Depth Information
var color = successful == testCount ? "#0c0" : "#c00";
output("<strong>" + testCount + " tests, " +
(testCount - successful) + " failures</strong>",
color);
}
Using the new setUp method, we can add an object property to hold the test
fixture, as shown in Listing 1.13
Listing 1.13 Using setUp in the strftime test case
testCase("strftime test", {
setUp: function () {
this.date = new Date(2009, 9, 2, 22, 14, 45);
},
"test format specifier Y": function () {
assert("%Y should return full year",
this.date.strftime("%Y") == 2009);
},
// ...
});
1.4 Integration Tests
Consider a car manufacturer assembly line. Unit testing corresponds to verifying
each individual part of the car: the steering wheel, wheels, electric windows, and
so on. Integration testing corresponds to verifying that the resulting car works as
a whole, or that smaller groups of units behave as expected, e.g., making sure the
wheels turn when the steering wheel is rotated. Integration tests test the sum of its
parts. Ideally those parts are unit tested and known to work correctly in isolation.
Although high-level integration tests may require more capable tools, such as
software to automate the browser, it is quite possible to write many kinds of integra-
tion tests using a xUnit framework. In its simplest form, an integration test is a test
that exercises two or more individual components. In fact, the simplest integration
tests are so close to unit tests that they are often mistaken for unit tests.
In Listing 1.6 we fixed the “y” format specifier by zero padding the re-
sult of calling date.getYear() . This means that we passed a unit test for
Date.prototype.strftime by correcting Date.formats.y . Had the lat-
ter been a private/inner helper function, it would have been an implementation
 
 
Search WWH ::




Custom Search