Geeks With Blogs

@CaffeinatedTwit
  • CaffeinatedTwit It would also be nice if google added some sarcasm filters about 1786 days ago
  • CaffeinatedTwit "Singletons are evil" = 739,000 results..."Singletons are aewsome" = 384,000 results...Evil clearly wins. about 1786 days ago
  • CaffeinatedTwit @mpool Noob! You obviously haven't had enough practice when it comes to drinking at lunch. about 1798 days ago
  • CaffeinatedTwit Spent lunch at Borders working on a blog post for Monday. about 1798 days ago
  • CaffeinatedTwit I'm still in the mode where I'm trying to minimize the refactoring until I get the mocking framework more deeply integrated into our process about 1798 days ago
  • CaffeinatedTwit Just discovered the outref option in rhino.mocks. Opted to use that instead of refactoring legacy code to a return object this time. about 1798 days ago
  • CaffeinatedTwit First time posting on twitter in a couple of weeks and the update fails. Good to know things haven't changed much. about 1799 days ago
  • CaffeinatedTwit Overheard: Is there anyone I can talk to there who is having a better day than you are? (coworker to DMV worker) about 1799 days ago
  • CaffeinatedTwit Installing the final version of R# 4.0. Been getting lots of errors with the pre-release version I am using, so hopefully this will help. about 1807 days ago

Caffeinated Coder A Grande, Triple Shot, Non-Fat Core Dump by Russell Ball

Participating in the open source community and becoming an avid code reader were two themes in my six month roadmap to becoming a better developer. I made progress in both of these areas in the last few days by downloading and exploring the source code for WatiN, an open source library that I have used recently for creating automated web tests. I still have quite a bit more exploring to do before I'll fully grok how WatiN works, but I thought I would share a few of the code reading techniques that I've been finding helpful.

My preferred starting place on any new project that has good unit test coverage is to pick some unit tests for common scenarios and then run them through the debugger. I chose the Google() test from the IETest class in the WatiN test project because I had done the equivalent in my own test code when first learning how to use the library. As a side note, this was the first time that I've used the Resharper test runner and I was duly impressed (I'll wait until the next post to share my thoughts on how it compares to other test runners).

Once I get a feel for the style and basic flow of the code through some of the common usage paths, I then find it helpful to use Resharper's Type Hierarchy window and VS's Class Diagram to explore the inheritance hierarchies.

The Type Hierarchy window window in Resharper works well when I am in the middle of examining code and want to know more about the classes being used. Several other options under Resharper's Go To menu, such as Usage, Inheritor, and Base also work well for this type of exploration.

 

 

Finally, at some point I usually want to understand the big picture and see how all of the classes relate to each other. In this scenario, the View Class Diagram in the Visual Studio Team Edition really shines. It is especially nice since you can adjust the level of detail you see and then simply jump back into code by double clicking on a class whenever you are interested in a particular member.

 

Here are a few setup notes to keep in mind if you decide to download and build WatiN yourself:

  • I downloaded the 2.0 zip file that contains the source, but
    the solution file that comes with it appears to still be in a 1.1 format because it prompts you to upgrade the project when you open it in VS2005.
  • You will then get a compile error that the name 'isSTA does not exist in the current context' because the required conditional compilation symbol is not set in the solution.You will need to add 'NET20' to the Conditional Compilation Symbols field on the build tab under the project properties.
  • In order to get the Test project to compile, you will need to download the Rhino.Mocks dll and fix the missing reference.
  • Depending on which test runner you use, you may find that the majority of tests fail due to the apartmentState not being set to STA, which can be fixed with a config file change.The Apartment Thread needs to be set to STA because WatiN uses COM interop with Internet Explorer.
  •  
    If you try to download and upgrade the 1.1 version, the project will have an invalid reference to Interop.SHDocVw because VS2005 has a different wrapper around IE than VS2003. In this case, you'll need to manually remove the invalid reference and add a reference to ShDocVw.dll from the System32 directory.

Happy spelunking!

Posted on Thursday, September 6, 2007 1:32 AM Becoming A Better Developer | Back to top


Comments on this post: Adventures in Open Source: Spelunking WatiN

# re: Adventures in Open Source: Spelunking WatiN
Requesting Gravatar...
I keep hearing good things about WATiN, I am going to have to check it out...
Left by Robz on Sep 07, 2007 2:50 PM

Your comment:
 (will show your gravatar)
 


Copyright © Russell Ball | Powered by: GeeksWithBlogs.net | Join free