[Kmymoney-devel] CSV Importer Plugin
asoliverez at gmail.com
Mon Feb 22 14:23:07 CET 2010
On Mon, Feb 22, 2010 at 10:07 AM, aga <aganderson at ukonline.co.uk> wrote:
>> > I've been doing a bit of reading up, and yes, I can see that. Already,
>> > I've had to do a bit of redesign to allow testing. Plus, I'm going to
>> > have to move some error messages for the same reason.
>> > Just thinking ahead slightly, so far I've been working on a free-standing
>> > version so as to get a simple executable and not mess things up in the
>> > process. What I'm unclear on is integrating back into KMM.
>> > Is it something like 'make test' and then run as normal, or what?
>> To run the tests, you have to enable the tests in cmake or ccmake.
>> Then, you make and make install, as usual, and finally you run make test
> Thanks for that.
> Sorry, but a couple more queries.
> Firstly, to do with testing. I've concentrated so far on my date conversion
> routine, and I've been throwing a bunch of good and bad date formats at it.
> If a valid date is found, I can unit test against the expected output.
> However, if an invalid date is found, not by unit test, but by the checking
> routine, the error return just bypasses the unit test ASSERT test. Is that
> the proper way to handle a program detected error, or what?
For these cases, you have to decide how you want to handle exceptions.
Usually, for these cases, the wrong dates are an expected error, so
you should check that before even reaching the ASSERT clauses, and
fail gracefully, warning the user.
You could throw a MYMONEYEXCEPTION, that your plugin catches and then
displays a message to the user. In the unit tests, you catch that too,
and add an assert to verify that the proper exception was thrown.
Are you familiar with try/catch statements?
> Secondly, I've not done anything about locales. Perhaps I'd better look into
> that first before asking daft questions. Then I'll ask them.
More information about the KMyMoney-devel