5

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:

  1. 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.

  2. Hopefully have some type of CSV, config, or other method he can change variables to run certain tests on.

  3. 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).

Community
  • 1
  • 1
djangojazz
  • 14,131
  • 10
  • 56
  • 94
  • Please tell me why this is getting downvoted? Honestly UI Automation is a big part of coding and getting downvotes without comments is pretty snobby to say the least. I have provided what I have done, what I want to accomplish, and what I would like. If this does not fit the model, tell me why or if it should be moved. – djangojazz May 05 '14 at 17:10
  • My best guess is: wall of text. I've actually read the entire question and I think its clear what you're asking so you have my +1. I'd be interested to see how this can be done as well. If i understand correctly, you want something reflection based i imagine? to discover and to inject variables for testing purposes? – Maverik May 09 '14 at 16:42

2 Answers2

5

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.

Daniel Mann
  • 57,011
  • 13
  • 100
  • 120
  • I was looking at coded UI and MTM already. One of the issues is I would like a tester or QA person not having VS to be able to run the tests. Can you build and run unit tests from just the binary of Unit Test project/solution? Like I said I am a total noob at unit testing so I have never gotten into the Unit Tests projects myself. The issue will also be that we are using Dev Express with Prism so some things HAVE TO BE tested for navigation in the code behind. – djangojazz May 11 '14 at 14:12
  • 1
    With MTM, absolutely. You can set up a test plan that's tied to a build (which contains your test assemblies), then tell MTM to execute the test run. MTM then talks to Lab Manager and runs the tests on the appropriate lab machine. – Daniel Mann May 11 '14 at 21:00
  • The one last consideration may be that we decide not to get Premium due to price. If that was the case do you know if you can code Regular ole Unit Test Projects to link and run under just the web portal of TFS 2013? My biggest concern is if I could give the binaries to someone not having VS to run from their desktop or a hosted way they could run them. – djangojazz May 16 '14 at 16:01
  • I believe not, the Coded UI assemblies ship with Premium, so you need a Premium CAL to run them. You could also use an alternate tool like Selenium instead of Coded UI, which can do many of the same things as Coded UI, but is free. – Daniel Mann May 17 '14 at 04:31
1

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.

Dirk Bester
  • 1,791
  • 19
  • 21
  • This looks more like a Toolkit to 'create' MVVM style not 'test' it. But I do like that as I was looking for something like this to enable faster creation of ViewModel parts potentially for existing views and/or models. – djangojazz May 16 '14 at 15:34