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
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
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
3. You need to create an interface for the Host and the Host Events so they are COM visible
The host class also needs the following attributes to make it visible via COM
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
This is done by using the WithEvents key word when you declare the host which allows you to add an event handler.
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
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