Testing WinForms / CompositeUI GUI with SpecFlow, White, Spring and MS Test

I have a C # desktop application (CompositUI / WinForms). This application connects to the web service using SmartClient. My task is to introduce (modify) tests into this application using SpecFlow and White systems. To just check the GUI, I need to make fun of the webservice calls. The class that connects to it is introduced through Spring.net. My task is to test an application that can make fun of a webservice call during tests, which means that my test code must control what my layout will do. Problem: The method that launches the GUI simply does not return control to the thread that called it. As a result, we cannot control the graphical interface and mocks.

So I have the following questions:

  • Is it doable (and if so - how to do it) to run the GUI in a separate thread and return control to the test thread?

  • What would be other ways to run graphical tests that would allow me to control the injection?

+6
source share
1 answer

To test the .net UI, you will need to use the MVVM toolkit or create one so that you can customize your solution to test the methods used in the user interface. There are a number of frameworks for .net that support this can be found on Wikipedia .

The fundamentals that underlie all MVVM UI tests are the DI / IOC structure that you will also need to choose.

Essentially, you are creating a ViewModel class that you can verify. Unit Testing Example with WPF - http://www.markermetro.com/2010/07/technical/mvvm-light-and-unit-testing-example/

Now there are a few issues to think about. First, .NET WinForms will not have major changes with M $ (THANKS A BUNCH!), And XAML / WPF does not have an update path. MS $ indicated that developers should start using WPF interface designers to promote projects on the desktop. The number of MVVM frameworks that support WinForms is limited, so you may have to minimize your own through DI, but look at fooobar.com/questions/44510 / ... for a discussion of the topic.

Secondly, .NET Forms for WPF for Windows Phone for the web interface to solve problems with the Metro UI. The Microsoft P & P team was created. Prism for xaml / WPF has some anti-Injection Dependancy Injection patterns ( Service Locator - BAD ) according to Mark Seemann and its .NET Injection Dependency . Prism has not been upgraded to the subway and redesigned, confuses adoptive parents and makes it partially redundant. Essentially, I want to say that creating a framework that allows your application UI to move forward will be difficult.

-1
source

Source: https://habr.com/ru/post/910914/


All Articles