Search the web
Sign In
New User? Sign Up
TestFirstUserInterfaces
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Show off your group to the world. Share a photo of your group with us.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Re: [TDD] TDD:ing MFC   Message List  
Reply | Forward Message #987 of 1052 |
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




Fri Jun 15, 2007 1:40 am

phlipcpp
Offline Offline
Send Email Send Email

Forward
Message #987 of 1052 |
Expand Messages Author Sort by Date

... 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 ...
Phlip
phlipcpp
Offline Send Email
Jun 15, 2007
1:40 am

... Modulo the legacy implications. Tip: Find the lowest-level functions you can, maybe things as simple as a glorified strcat(), and write unit tests on them....
Phlip
phlipcpp
Offline Send Email
Jun 15, 2007
12:03 pm
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help