I am currently developing a library and a set of programs using this library, in python. Unit testing dictates that I import each module from the library, and test the classes and routines within. No problem with that. I have a separate test directory containing all my tests and importing the library modules, which I run while developing.
However, when it comes to testing the programs, things change. To be tested, the programs must run as a whole. The programs assume to find the library installed (which could actually be the case, albeit wrong, if I installed a previous version of it on my machine, adding further trouble). At the moment, my programs are run by a testsuite with a PYTHONPATH definition that I perform by hand, before the deployment (IOW, I don't perform the install), but I don't think I am doing it right. I feel like in general, a program should be tested for functionality when fully deployed, but this would mean that I have to install it every time I want to perform functional testing.
What is your experience and suggestions concerning functional testing of whole programs ? do you do it before or after deployment, and how?
Thanks
Note that I don't include the python tag on purpose. Although my problem is python specific, and I would prefer python-related answers, I think that contribute can be brought also from experts in other languages.
Edit: as reported in a comment, the fact is that my program, when installed, has to import modules whose path can be found only when deployed (I download and install the dependencies on the fly, they are not installed on my machine). I cannot manipulate sys.path from the test, because that would imply that I modify the sys.path of a program (my executable) from another program (the testsuite, which runs and spawn a system() call).
In other words, the only way I have to test the program without deploying is to execute the program with PYTHONPATH set to the dir containing the deps and the library that program uses installed by the make script (which, as I said, downloads, compiles and "installs" everything in a temporary directory).
At deployment, the deps and the executables are packaged together in a "OSX bundle"-like structure, which is fully executable and relocatable.
Edit:
added a 150 bounty to see if I can get a little more feedback.
Edit:
I appreciated all the answers and voted up all of them. The choice has been a hard call for me, but I've been recalled by LudoMC of the V-model approach to testing I studied long ago. Thanks to all for the very good answers.