简体   繁体   中英

Testing a .Net C# WPF MVVM application from an external application

I have a largish application that uses MVVM. The Model is mostly in a C++ DLL. The ViewModel is in C#, and I've tied my WPF controls to the ViewModel in the usual way.

The app is ready for integration testing. I can drive tests from within the application, but I'd like to move testing out into another process so I can minimize polluting the application with test stuff.

I'd like to write the test application myself in C# and WPF, but I'm a bit stuck as how to go about it.

Note: If there's a third party testing application for testing ViewModels inside a .Net application, I'd love to hear about that too!

I imagine Process.Start is the initial way in, but from there I'm lost.

Basically I need to let the application load up normally, create its Model as usual, and start the GUI, so I can't drive individual methods in isolation (unit test style). Then I would like to set and get my ViewModel properties as I do currently with my local tests.

I've looked at James McCafferey's MSDN 03/09 article on testing WPF apps, but it's geared towards testing the GUI (basically remotely pressing Buttons etc), something I want to get away from.

Is reflection the way in here? If so, how, bearing in mind I can't simply reflect onto an 'empty' ViewModel, it has to be connected to my Model for the VM properties to be testable.

Thanks in advance

Basically I need to let the application load up normally, create its Model as usual, and start the GUI, so I can't drive individual methods in isolation (unit test style).

IcuTest ( http://IcuTest.com/ ) is what you're looking for. It let's you start the app in a unit testing framework AND let's you interact with your Models and methods.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM