Prev | Current Page 331 | Next

L. McColl-Sylvester and F. Ponticelli

"Professional haXe and Neko"

The developer
community provides many strategies to deal with these problems and going much deeper in Unit
Testing techniques is beyond the scope of this book.
The haxe.unit Package
The standard library provides a very small but very useful package to write and run tests. The package
contains just four classes, two of which are of interest to the programmer: TestCase and TestRunner .
TestCase and TestRunner
A test is a single function inside a class. The function must have a name that starts with the lowercase
test keyword. This convention is used to distinguish between the methods that are really tests and the
ones that are just helpers. The container class must extend the TestCase class. The class will inherit a
very small set of functions (see Table 6 - 5 ) that will be used to write the tests.
Table 6- 5
TestCase Method Description
setup() : Void This function is invoked automatically before each
test is executed. In the TestCase class its
implementation is empty; when overridden it must
set the context so that the test can work as
expected.


Pages:
319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343