Hi There
Has anyone tried using CPPUNIT unit test tool for an MFC application? My application is MFC based and it has property sheets, property pages and dialogs. How do I use CPPUNIT for unit testing this MFC application. I understand the tool's usage for normal C++ classes like ComplexNumber, BoardGame, etc. But I would like to know how to use it with my MFC application. MFC application is also C++ based but they differ in that it involves UI components(window pointers). Also, there are lots of inter dependencies between the objects. If someone can provide an example that would be excellent.
I appreciate any feedback on this.
Thank you very much,
Ramani
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Testing UI's is always tricky because of their nature. The trick is to take out as much of the application logic from the UI layer as is possible, and put it into non-gui classes. One of the notable caveats of unit testing is that you shouldn't test other people's code. So seperate as much of the MFC stuff from your code as possible.
One other point is that you've noted that there are lots of interdependencies between your classes, this is often indicative of high coupling. These dependencies should, where possible, be kept to a minimum. One of the happy side effects of unit testing is that is produces code with low coupling, since to test a method or class, it must be loosely coupled.
Cheers,
Tim
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Hi There
Has anyone tried using CPPUNIT unit test tool for an MFC application? My application is MFC based and it has property sheets, property pages and dialogs. How do I use CPPUNIT for unit testing this MFC application. I understand the tool's usage for normal C++ classes like ComplexNumber, BoardGame, etc. But I would like to know how to use it with my MFC application. MFC application is also C++ based but they differ in that it involves UI components(window pointers). Also, there are lots of inter dependencies between the objects. If someone can provide an example that would be excellent.
I appreciate any feedback on this.
Thank you very much,
Ramani
Testing UI's is always tricky because of their nature. The trick is to take out as much of the application logic from the UI layer as is possible, and put it into non-gui classes. One of the notable caveats of unit testing is that you shouldn't test other people's code. So seperate as much of the MFC stuff from your code as possible.
One other point is that you've noted that there are lots of interdependencies between your classes, this is often indicative of high coupling. These dependencies should, where possible, be kept to a minimum. One of the happy side effects of unit testing is that is produces code with low coupling, since to test a method or class, it must be loosely coupled.
Cheers,
Tim