Paula S. wrote:
> I know some people are successfully doing TDD with VC++ MFC. I'm currently
> trying to add unit tests to a legacy MFC application and need some help to
> get started testing dialogs and windows. Some pointers in the right
> direction would be much appreciated.
MFC has major architectural flaws that resist clean testing. One good policy
is to use "in vivo" testing, per the book /Working Effictively with Legacy
Code/ by Mike Feathers. That means you start the application's main work
loop, and after the main window has painted you encounter a line of code
like this:
#ifdef DEBUG
runTests(mainHwnd);
#end
That means when you run your program from VC++, in Debug mode it will invoke
a test rig, and pass in a handle to the main window. The tests now operate
on the window, treating all its subwindows and controls as objects.
I would use UnitTest++ for the test rig. It's designed to be lean and
non-invasive (unlike MFC), so you'll easily squeeze it into the runTests()
function.
Ask about any more questions!
--
Phlip
http://www.oreilly.com/catalog/9780596510657/
"Test Driven Ajax (on Rails)"
assert_xpath, assert_javascript, & assert_ajax