From: Kristofer S. <k....@sa...> - 2003-04-10 11:02:29
|
> This can, of course, be made into a general method: > procedure ExpectException(const AMethod : TTestMethod; Exceptions > : array of const); <...> > Unfortunately, you can't use local methods for this, so you'll have > to divide up your testcase into several small methods, and have it > all communicate through private fields. A bit annoying... It's a tradeoff, the elegance and readability of a straight left margin (no inline repeated/nested try-except clauses and indentation/branching) vs. the nesting/delegation of test code to lower level test-subcases. What I think we really need here is a new language feature, a sort of inverse try-except block! Would allow to write code like this: TryExpect([EMyException,EOtherException]) DoBlah(0,nil,NastyValue); EndExpect; EndExpect swallows exceptions of the declared types, and if no exception is raised, EndExpect will raise its own EMissingException. But somehow I don't think Borland finds our little corner of the world interesting enough to implement language features for. <g>. Kristofer |