Hi Scott,I don't see a strong need for making dynamic calls for unit testing.However having static(private) functions would probably help a lot.
(also in terms of writing a library)
In the case of your Gt library I would add a testing section at the end of the code for each individual library source file which could be left out for normal compiling using the pre processor .In testing mode you could compile 1 test program per source file.This reduces the need to care too much about names.
In the simple cases you just need a MAIN() function to test your library code.
fglrun -D UNIT_TEST libgt_email.4gl
fgllink -o ut_email.42r libgt_email.42m libgt_unittest.42m
&ifdef UNIT_TEST
FUNCTION test_email_lib(...)
END FUNCTION
FUNCTION MAIN()
CALL test_email_lib("localhost",25)
CALL test_email_lib("foo",25)
END FUNCTION
&endif
This is basically what we do:
we try to put a functional test into a separate program and check for errors.
If the program runs through the test was ok(so we save a lot of "Passed" code lines...)If at some place of the test program was an error, we exit the program with something else than 0(FGL tests 125,GDC tests 1)
For example in the gdc tests we call a function qa_error() which prints the
error string , the stack trace and terminates the program
FUNCTION qa_error(errorstring)
DISPLAY "ERROR:",errorstring
DISPLAY base.Application.getStackTrace()
EXIT PROGRAM 1
END FUNCTION
(Getting the stack trace prior to 2.11 was only possible to raise an error,
thats why we also have &ifdef'ed code which does something nasty:
DEFINE dummy om.DomNode
DEFINE foo STRING
DISPLAY "ERROR:",errorstring
LET foo=dummy.getAttribute("foo") --at this point the program stops and displays a stack trace
Our test runner program written in 4GL basically loops over all test directories,figures out which tests are to run using some conventions and does collect the information which test programs failed using the return code.
It captures also the output of the ERROR string and strack trace and sends the results via mail multiple times per day.
HTH and Kind Regards, Leo
P.S. Would you like to write unit/regression tests also for your INPUT/DISPLAY ARRAY/INPUT ARRAY statements ?