Hi Atul,
I tried to execute the commands from your script but get an error at the first command:
~/calitko-0.5.4-atul/UnitTest$ print ../**/*.cpp(:h)
-bash: syntax error near unexpected token `('
Which shell do you use?
I find writing a script that automatically duplicates the directory structure a lovely idea! Could you write a script (I think Perl might be better) that can keep the main tree and the Testing subtree in sync? That would be pretty much what your first command is supposed to do - create the same directories. It would further be useful to have an option to list all source files for which no test file was found. This way somebody who is willing to write tests can check what is still not covered. It would also be nice if the script could tell whether test exists for sources that do not exist. What do you think?
Now regarding symlinks. They would work perfectly under Linux/Unix but I don’t want to cut out Windows developers and most of them use MinGW (though symlinks would work in MSYS). That’s the reason why I suggested that the actual source file be included in the test source file. We additionally save ourselves the trouble to write double entries in the pro file.
Also instead of writing a Makefile for the tests I’d prefer to do all using qmake pro files as qmake will always generate the correct makefile for each platform and compiler. How do you suggest that the unit tests makefile should be invoked? The test executable should be built before the Calitko executable? I guess there would be a way to define a post-build step for the tester, which will execute it, so that building Calitko will be done only if test build and execute without failures. Is that how you see whole picture?
I was thinking that it would be so much easier to do development using the test executable. I’d also like to have integration tests in the Testing sub-project. So that would mean maybe writing a “unit” test (in CppUnit terminology, although actually an integration test) for the controller object of a subsystem. Do you have any experience with that kind of testing?
Regards,
Peter
atul wrote:Dear all
The previous one got garbled somehow ;-)….
Here is a repost and the script file is attached…
I thought a lot about this and fr now have settled for the following:
1. There is a UnitTest directory added in calitko top level dir
2. The sources directory structure where even is replicated … What I mean is if there is a .cpp or .h file in the original source tree, that directory is created ….
If you run the first command in the attached scritp file I mean….
3. Next every source file found in the original source tree, a symlink is created in the UnitTest directory with a u prefix ( the second line in the script ….
it looks a bit hairy for non unix users so I can explain it in detail if needed
)4. Now I can write a makefile and there is no danger of overwriting a .o file ( as the directory and names are very different ;-)
5. UNIT_TEST will be defined only in the UnitTest Makefile and so running make
&& ./calitko runs the test cases. The original Makefile and ./calitko are not touched at all6. But the sources are shared ( that is why I am using symlinks ;-)
I will post the unittest makefile once I finish writing some tests… ;-)
7. From the main makefile we can trigger the make and run of unit tests
For Windows users: If you are using cygwin, things should work as given…
Let me know what you all think….
—- cheers atul
