Hi!

I'm refactoring and putting INTL in the new API, and a need I have is to
write test code, with in current Firebird code, should be discarded or
will not be maintained and used. This test code is not necessarily
SQL/API code (as I'm doing things, engine is not even fully runnable).

A much better approach would be to have unit tests in the core code.

I had good experience with Boost Test library in another projects.

It could be setup to be a header-only library (with the library itself
being included in a single file) and that makes usage in Firebird code easy.

As I said in the other thread, it has some integration difficulties, but
things we should resolve anyway.

So about tests, we could do it this way.

We have in our code static library (common), dynamic libraries and
executable utilities. All of them could have test code.

Test code could be turned on/off (via #define and #ifdef and configure)
with debug and release builds. It would be activated by default in debug
builds.

Testable executables may have special code in main function that if some
environment variable is set, it starts tests and exit, instead of start
the actual utility.

Dynamic libraries could have "run_tests" function exported, and a very
thin utility (dlopen/dlsym/dlclose /
LoadLibrary/GetProcAddress/FreeLibrary) loads the library and call
run_tests.

That would avoid we have more complicate build with special test
executables for them.

Test code in static library is more problematic. It could be embedded in
the executables and dynamic libraries and tested there, but then it
would be run more than one time or not run at all.

For example, for templates (say array.h), it would need a specific test
file. When that test compiled file is put in common.a and embedded in
another project, it will not be linked as nobody else references it. I
guess the same will happen in Windows too.

So for common we could have a special common test executable.

Its tests will also be embedded in the others projects, but they could
be switched off when running the tests.


Adriano


Firebird-Devel mailing list, web interface at 
https://lists.sourceforge.net/lists/listinfo/firebird-devel

Reply via email to