KUnitTest progress

Frans Englich frans.englich at telia.com
Thu Apr 14 14:47:16 BST 2005


On Thursday 14 April 2005 09:10, Jeroen Wijnhout wrote:
> On Thursday 14 April 2005 03:18 am, Frans Englich wrote:
[...]

> > Is it possible to check for thrown exceptions? Is it something you plan
> > to add?
>
> No, not really. How is this supposed to work (from the perspective of the
> user of the library)?

I'm not sure. Here's an example from PyUnit, the unit test framework shipped 
with Python:

   def runTest(self):
            self.assertRaises(ValueError, self.widget.resize, -1, -1)

It calls self.widget.resize with the arguments -1 and -1, and checks that the 
ValueError exception is thrown. Something similar could perhaps be done with 
a macro expanding to a catch statement with what exception that was 
specified, nested by a catch(...).

>
> > To my experience, it is not very C++-ish to communicate different errors
> > through an exception class hierarchy, but it would nevertheless be useful
> > to test whether an interface throws an exception or not. Perhaps it's
> > doable with macro magic, as well as detecting whether the exception is on
> > the heap or stack, and needs deletion..
> >
> > Another question: is it possible to document tests inline? IMO & FWIW,
> > tests tend to become obscene, and to make clear what they test, their
> > essence, is essential to make use of them. I would even go so far and
> > suggest that the GUI could issue a warning(in a console or similar) if a
> > test without documentation is encountered, and have a tool tip explain
> > the importance of documentation such that the user feels motivated. For
> > the reason of helping the programmer towards good habits.
>
> What's wrong with comments in the code? Or do you want to be able to view
> the documentation in the GUI? That would be neat of course, but I'm not
> sure if it is worth the effort since double-clicking on a failed test in
> the details widget (the bottom one) will take you to the corresponding code
> in KDevelop (if you have a KDevelop application running) anyway.

Yes, it would be a matter of convenience. But as you say, it's about priority 
and that it's available in KDevelop.


Cheers,

		Frans




More information about the kde-core-devel mailing list