Integration testing with Fit/FitNesse

Sep 30, 2007 at 12:01 AM
Did anybody succeeded with Fit testing CAB (WPF) applications?
I can see how Views can be swaped out using a catalog. But what about workspaces? Workspaces are UI elements, and I feel should be also swapped out for non-GUI integration testing/acceptance testing.

Anybody?
Oct 2, 2007 at 5:15 PM
What is Fit/FitNesse ?
Oct 11, 2007 at 3:44 PM
Edited Oct 11, 2007 at 3:46 PM
Long story short, we have modified CAB to intercept SmartPart, WorkSpace, Items, and WorkItems creation such that we will look into an InterfaceMappingService to determine the concrete type to create.

For example we can write the following code:
workitem.SmartParts.AddNew<IMyView>();

if our XAML User Control has been decorated with [SmartPart(InterfaceType=typeof(IMyView)], the code above will return an instance of MyView. If our class MyFitNesseView has been decorated with [FitNesseView(InterfaceType=typeof(IMyView)] the line of code above will return an instance of MyFitNesseView.

Here is what we have done in our organization:
  • Create an InterfaceMappingService in CAB
  • Extend our Library.DependentModuleLoaderService.InnerLoad method to execute a set of visitors for each module to load
  • Extend SmartPartAttribute to include optional named parameters (InterfaceType, ProfileName)
  • Create a SmartPartRegistry visitor that is used by the DependentModuleLoaderService. This visitor is executed after LoadServices and Before LoadWorkItemExtensions and LoadModuleClasses. This visitor discovers all exported types that are decorated with our extended SmartPartAttribute. For each type decorated with the extended SmartPartAttribute, register the concrete type to create with the InterfaceMappingService.
  • Extend ManagedObjectCollection such that the ManagedObjectCollection contains a virtual method (GetMappedType). Subclasses can override the GetMappedType method and use the InterfaceMappingService to locate concrete types for given interfaces.
  • Refactor ManagedObjectCollection such that calls to Add and AddNew call to GetMappedType before moving on to the Build method of managed object collection
  • Create a subclassed ManagedObjectCollection that overrides GetMappedType (InterfaceMappingManagedObjectCollection). This is basically a managed object collection that checks the InterfaceMappingService before delegating to the Build method of ManagedObjectCollection.
  • Refactor WorkItem such that the SmartPart, WorkItem, Workspace, and Items collection are all InterfaceMappingManagedObjectCollection
  • Refactor CabApplication such that the AddRequiredServices method adds the InterfaceMappingService
  • Modify our Fit.Shell so that our Fit.Shell sets the ProfileName property of the InterfaceMappingService to "FitNesse"
  • Refactor all smart parts and workspaces to use the [SmartPart(InterfaceType=typeof(IMySmartPart)]
  • Refactor all FitnessViews to use the [FitnesseView(InterfaceType=typeof(IMySmartPart)]