Download Summary

Transcript
Chapter 7
That's it! Now, let's run this test from the command line. Assuming that the phpunit
executable is in your path, you type the following command and observe the output.
PHPUnit starts out by identifying itself, its author, and the version that is running.
The single dot on the next line represents a successfully executed unit test. In
particular, the assert statement in our testNumberOfMatches() method turned out
to be true. If the assert had failed, the dot would have been replaced by a letter "F"
for failure. PHPUnit would also provide us with some details about which test failed
and display the corresponding error message.
Temporarily modifying our test to expect a different number of results, we can force
the unit test to fail. The corrsponding output is as follows:
Extended test class features
Having a test class with a single test is not quite in the spirit of unit testing. Our
goal is to create enough tests to cover most or all of the scenarios our code is likely
to encounter in production use. In this section, we will work towards that goal by
adding additional test methods and by using different sets of data for the tests we
have created.
[ 309 ]
Download from Wow! eBook
www.WoweBook.com