Communication Hurdles when creating a UI Test Extension

The Problem

One of the biggest problems I faced when creating a UI Test Extension how does the extension communicate with the application you are testing. For me there were 2 major boundaries I had to cross.

· Interprocess communication

· Technology Boundary

After a lot of research I kept hitting the issue that I was limited to the fact that the application we want to test is in VB6. The end result meant I had to be a bit creative. The result is the below diagram

clip_image002

After trying to break the Technology and Interprocess boundary and failing I realised that the interprocess communication does not have to support VB6. Instead we can use the latest .net technology and host this in our VB6 app using COM. The original Excel Extension supplied by Microsoft uses .net Remoting but I decided on using WCF for a couple of reasons. The first is that I already knew a bit of WCF and the second was everywhere I read bout Remoting suggested that you should use WCF instead if you have the choice. It seemed like Remoting wouldn’t have the support moving forward.

Proof of concept

So I started working on a Spiking project to prove the concept. The spiking project works like this.

1. The .net client Submits and Gets a list of evals from the WCF Service hosted by the VB app

clip_image003

2. When an Eval is submitted the WCF Service triggers an EvalsReceived event to be published which the Com visible host class subscribes to via a singleton and then republishes so it is visible via COM. This might seem a bit strange but it’s because you can’t have a singleton or static class that is com visible to ensure both the VB6 and the .net WCF Service was subscribing to the same objects events. The republishing of the event looks like this but there is a bit of a trick to making the hosts Eval Received event COM Visible

clip_image005

3. You need to create an interface for the Host and the Host Events so they are COM visible

clip_image006

clip_image007

The host class also needs the following attributes to make it visible via COM

clip_image008

The Host does not implement the IHostEvents interface. The source uses this interface as a method to subscribe to the event.

4. The VB6 app responds to the event

clip_image009

This is done by using the WithEvents key word when you declare the host which allows you to add an event handler.

clip_image010

image

 

5. The VB6 app response to the Event and calls a callback method on the Host. Which write a message to the debug window in .net

clip_image013

 

Source

It’s a little bit more complicated than what I have shown but you can check to source. I’ll go into more detail when writing the extension

Advertisements
  1. Creating a UI Test Extension for Coded UI and Action Recordings « Ryan Burnham's Blog

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: