[Kmymoney-devel] CSV Importer Plugin

aga aganderson at ukonline.co.uk
Mon Feb 22 17:31:34 CET 2010


On Monday 22 Feb 2010 13:25:53 Thomas Baumgart wrote:
> On Monday 22 February 2010 14:07:32 aga 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.
> 
> In that case, it is a strick requirement for unit testing to know when you
> throw a good one and when a bad one. In either case you know the expected
> result and should check for it. Throwing a bad date format and detecting it
> is a PASSED.
> 

Yes, that's understood.

> > If a valid date is found, I can unit  test against the
> > expected output.
> 
> As said, you can also test for the expected output of a bad format, or am I
> missing something? I have to admit, I haven*t looked at any of this (yet).
> 

Initially, I had a series of ASSERT test, testing for expected against actual.  
The ones that were expected to pass, passed.  However, the first test with an 
invalid date was pre-empted by the check within the date checking routine, 
which displayed a warning message box.  What would then happen, normally, was 
that this would be acknowledged, the erroneous date would be passed to QDate, 
which also, of course produced an error as in qifreader, allowing aborting or 
substitution of the current date.  But, in unit testing, there was no expected 
data to check against.  So, what I did then was, for the expected failures, I 
preceded the ASSERT  with a check for a valid date being returned.  So, if the 
date was valid, the ASSERT was performed.  But, because the date was not 
valid, the ASSERT was skipped.  All very stupid really, hence my query.

I've been thinking whilst writing this and I think I know now what I want to 
do.

> > 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?
> 
> Again, the unit test does not find anything related to the logic. It just
> finds if the behavior of a function is not as expected.
> 

Allan


More information about the KMyMoney-devel mailing list