[Gambas-user] Test Module, First try

Christof Thalhofer chrisml at deganius.de
Wed Jul 29 00:33:34 CEST 2020


Am 26.07.20 um 22:42 schrieb Brian G:

> Your method works very well as long as the number of entries, in both
> tables match but as soon as they don't, it throws an error and ends,
> I want to print out the full comparison to see what was actually
> delivered and what entries don't match.

I don't know what you really want to test. You are the only one who
knows what the state of your program has to be.

If the two arrays have to have the exact same count of entries, test it!

If every entry in the first array with index x hast to be identical with
array2[x], test it.

I saw that you printed out some variables, but that's not a test and
printing some strings is not the purpose of gb.test. It helps, while
debugging, yes, but as soon as your work is done, switch it off.

gb.test is there to test a predictable state of a program at runtime.
And if the predicted state of the program at runtime is not fulfilled,
gb.test will report that, the test will fail. This is what helps you now
and later on.

But it will report that only if you have asked the right question. If
you asked an ambiguous question, it may give you an answer, but that
answer could be ambiguous as well and that won't help you.

Therefor I recommend to do test driven development (TDD) in this way:

First write a test which lets your program run and tests whether the
answer of your program is right. Without the program it will fail. Then
write the program and test it until it does not fail any more.

If you have to write tests for a program that already exists, you have
to be very careful not to ask wrong questions.

Alles Gute

Christof Thalhofer

-- 
Dies ist keine Signatur

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: OpenPGP digital signature
URL: <https://lists.gambas-basic.org/pipermail/user/attachments/20200729/d8908049/attachment.sig>


More information about the User mailing list