Using MockViews (or something) to test CAB Views

Topics: CAB & Smart Client Software Factory
Sep 3, 2006 at 4:10 AM
originally posted by: JossB

Hi,
Hope you all can help. I need advice on the best way to set up automated testing of our CAB Views, we've stuck to the MVP pattern throughout. However, I can't figure out how to set up a CAB application that is "unattended" and tests our views without some poor guy having to do all the keying in!

I had thought we should be able to create Mock views to do this but I can't picture the "framework" in which this would happen.

Should I create another CAB Shell that uses all the same modules as our "real" app and instantiates Mock Views instead of the real ones? If so, how can I make a CAB Application that is not tightly linked with a Shell form (doesn't seem possible to me at the minute).

Any help greatly appreciated (I've a nasty feeling my jobs on the line!).
Sep 3, 2006 at 5:17 AM
originally posted by: bil_simser

I'm not sure I understand testing "CAB" views. Any user control you create in a module should be done using the MVP pattern. Given that pattern, you'll have an interface and presenter (or controller) to test against. You shouldn't need to test the shell because it doesn't do anything. So what is it that you're trying to test?
Sep 3, 2006 at 5:48 AM
originally posted by: JossB

Hi,

Thanks for getting back to me. The issue we have is that if our "model" bit of MVP requires Services or Dependancy Injection provided for us by the Composite UI App Block, then would we not need to have a Composite UI App Block based application to do the testing?

Or have we just designed it wrong (this is a distinct possibility as it's the teams first go)?

Joss
Sep 3, 2006 at 5:58 AM
originally posted by: bil_simser

Oh ok, not a problem. Our tests are the same. The view creates the presenter though DI and our services are tagged with a Service tag and created as a dependency. The secret is that you need your services to provide interfaces, then you can just mock them out with whatever code you want for the test.

There's an example in the Smart Client Software Factory called AppraiserWorkbench that mocks out the service agent and the web service proxy behind it via interfaces and then writes tests for the presenter (which is created with DI) so you might want to take a look at that as an example.
Sep 3, 2006 at 6:00 AM
originally posted by: JossB

Fantastic - Thanks so much.

I think you may have just saved my job!
Sep 3, 2006 at 8:13 AM
originally posted by: matiaswoloski

Hi,

Take a look at the reference implementations included in the Smart Client Software Factory 1. They include the unit tests for all the modules.
Also, take a look at this article 2 that shows how to code views and presenter using TDD.

1http://www.gotdotnet.com/codegallery/codegallery.aspx?id=941d2228-3bb5-42fd-8004-c08595821170
2http://staff.southworks.net/blogs/johnny/archive/2006/09/01/786.aspx

Thanks
Matias
http://staff.southworks.net/blogs/matiaswoloski
Sep 3, 2006 at 8:27 AM
originally posted by: JossB

Thanks Matias,

I was so confused about how to progress, but you guys have really put me on the tight track. Your seond example fits right in with my conterparts drive to introduce TDD into our development process. (Currently my company hardly even tests later, late alone first!)

Yours and bils replies have been really useful.

Thanks again.

Joss Burnett
p.s. apologies for any spelling mistakes: I've been up for about 24 hours....