I have searched and tried a few things already namely this thread:
How to test a WPF user interface?
I have tried getting started with Systems.Windows.Automation and TestAutomationFX(3rd party tool). My opinion is that while good for simple things, TestAutomation kind of bombs when it goes multiple UI levels down(a usercontrol within a usercontrol from a loaded assembly) and I may have to manually tweak their code behind to get what I want. System.Windows.Automation seems old and I would have to do everything manually which may take more time than I want to devote as I am not full time on automation creation. I have also downloaded the Inspect.exe from the Windows SDK for Windows 7, which works great for reflecting objects in my UI. Both testers run fine for simple code behind but then when it gets a few layers down it seems a bit involved. I was also going to try the 'TestSTack/White' on GitHub that moved from the original Project White.
I was curious if anyone had experience recently in UI automation that a non developer could use in a QA position. I was thinking of getting VS 2013 Test Pro but that seems like overkill potentially and is more expense than the VS 2013 Pro from what I could see. Basically this is not load testing or verbose complex dynamic entity results changing, just function testing with hopefully ten or so runs of different variables. It is just a more confusing layout as we are combining the Prism method, Microsoft.Practices.Prism, with MVVM as well.
I do not mind developing something in VS 2013 and .NET 4.5 but I was hoping to get something that I am not developing a whole other set of projects for, but to save time. I am an extreme noob at unit testing projects but the end goal is really:
Give a non developer an exe or some environment to automatically run a Click Once UI written in WPF following some Prism and MVVM architecture.
Hopefully have some type of CSV, config, or other method he can change variables to run certain tests on.
Have it be able to input the exe of the click once app in a config or changeable manner(Click Once is funny finding it in my experience of opening Task Manager and then 'open location' of the click once app, which differs from box to box).
This may be a lot to ask, or it may be simple for those that do unit testing every day, I dunno. I am up to try 3rd party products, non .NET products to run .NET, and coding in C# in VS to make a project(s) to run my UI(as long as it can be ran on boxes not have VS).
Prism: Patterns For Building Composite Applications With WPF | Microsoft Learn. This browser is no longer supported. Upgrade to Microsoft Edge to take advantage of the latest features, security updates, and technical support.
Prism provides an implementation of a collection of design patterns that are helpful in writing well-structured and maintainable XAML applications, including MVVM, dependency injection, commands, EventAggregator, and others. Prism's core functionality is a shared code base in a Cross Compiled .
Automation Expert. Windows Presentation Foundation (WPF) is a common framework used by developers to build applications for a Windows Operating System (OS).
Ideally, you wouldn't need to have many UI tests at all -- the bulk of your application's logic should be tested via unit tests. With MVVM, you can easily test your viewmodel to ensure that buttons are disabled/enabled when they're supposed to be, and so on.
Testing your core business logic via your UI is a recipe for disaster. Just don't do it. UI tests are very brittle and tend to need to be re-recorded or updated if your UI changes to any significant degree. If your tests fail for reasons unrelated to the core logic you're trying to test changing, you're less prone to trust that the tests validate what they're supposed to validate. If you don't trust the tests, you'll start to ignore failures. "Oh, that test fails sometimes, it's no big deal." If you can't trust your test to be accurate 100% of the time, why bother having the test?
So what you want to test via a UI testing tool is the very top-most level of the UI, just to make sure that your viewmodel is correctly bound to your view. This boils down to, really, just a handful of tests. For that, you can easily use Coded UI. The tricky part is making sure that all of your controls are automation-friendly, which does involve giving the controls proper names and making sure you're attaching the correct automation properties to your controls.
Coded UI is available in VS Premium and above, and you don't need to be using Microsoft Test Manager to manage and run the tests, although it's certainly easier.
It sounds like what you're really after is MTM, though. You want your manual testers to be able to record tests by interacting with your application, then play them back later. This is exactly what MTM was designed for, and what it excels at.
Sadly this answer sounds like too late for the stage you are at but I am happy with the basics of MVVM Light Toolkit:
Basically you start by setting up with some IOC container and dependency injection scheme and PRISM. Your Services can then provide design time, run time and test time implementations with mocking etc. There are some videos and tutorials but like most of wpf it is hard as a newcomer to sort through ancient obsolete stuff vs relevant best practices.
MVVM Light at least has a focus on enabling Blend to work at design time and smells like some kind of best practice.
Now for the part where this sadly does not answer your question: the idea is to be able to layout in Blend so you can see what things will look like without endless tweak-compile-run cycles. Testing is purely on the underlying ViewModel and Model. You then arm wave that the app works because the UI bindings are unlikely to be wrong / are relatively simple to manually run through and verify. That last part works for my project but may be deeply unsatisfying for yours.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With