Matching exception messages with regular expression

at 2010-09-18 in Unittests by friebe (0 comments)

The unittest API has been extended to support regular expression matching on expected exception messages. To make use of this feature, use a forward slash ("/") as the first character in @expect(withMessage). Here's an example:

  #[@test, @expect(
# class= 'lang.Error',
# withMessage= '/Call to undefined method .+::undefined()/'
#)]
public function callNonExistantMethod() {
$this->remote->lookup('xp/test/Calculator')->doesNotExist();
}
The real message is something like Call to undefined method Proxy?1::doesNotExist() from scope net.xp_framework.unittest.remote.IntegrationTest, but the class name is generated, and the scope may change when the class is moved, so we only want to check on parts of it. This new feature makes this possible.



Subscribe

You can subscribe to the XP framework's news by using RSS syndication.


Categories

News
General
PHP5
Announcements
RFCs
Further reading
Examples
Editorial
EASC
Experiments
Unittests
Databases
5.8-SERIES
Unicode
Language
5.9-SERIES

Related

Find related articles by a search for «Matching».