WPF - PRISM (CAL) - automated functional testing

1.3k views Asked by At

I'm currently new in a project that was started 1 year ago.

This project is using C#, WPF, PRISM (CAL), Entity Framework, LINQ, etc. The application is done using the MVVM pattern.

There are some unit tests, but I was asked to do functional testing because most of the bugs were found when using all the components together.

I started making a MSTEST project. My goal was to start the entire application back-end (model and viewmodel), simulate UI events and check the model modifications accessing on or more viewmodel properties.

My first guest was to create the Entity context (the model), initialize all the PRISM modules and start publishing events in the view-model to modify my model and check back the results in the same or other viewmodels. I had to :

  • Override the prism Boostrapper class
  • Create a simple application (because under MSTEST it seems that System.Windows.Application.Current is null). I just derived a class from System.Windows.Application.

I can access all of my interfaces implementation using the UnityContainer. The problem I have now is that the IEventAggregator is not working. Events are not fired. I don't want to mock the event aggregator because I want it to fire my events between the prism modules (I'm doing functional testing, not unit testing).

I found a way to make it work by playing with the Dispatcher and DispatcherFrame, but I get stock in the RegionManager that seems to fail.

My questions is: is there a better way to do my functional/integration testing without necessarily showing the user interface?

1

There are 1 answers

1
David Rodrigues On

If you're doing functional testing you should want to show the user interface. For example, if some ui designer decides to put a textbox on top of a checkbox and you can no longer click on the checkbox, this needs to be picked up in a functional test.

For that you have coded UI tests in Visual Studio, you will come across some issues with WPF, mainly controls that you can't easly reach in the coded UI mapping. But apart from that it works well, easy to build tests in, and integrates well with the TFS Build Agents and MSBuild.