简体   繁体   中英

Coded UI Test to test UI components in isolation

We are looking to write automated tests using coded ui test framework. We are looking to test the ui components in isolation without launching the application in a separate process.

For example if we have a pop-up dialog in the application to capture data from user, we would like to launch only the specific dialog and validate different use cases rather than running the whole application.

We tried to test by launching the dialog as part of the test initialize() but it is not able to find the controls... but the same test works fine if I launch the dialog separately.

Have anyone tried this or have advise to get this working ?

Coded UI Framework is a very powerfull framework yet has lots (and I mean LOTS) of problems.

I wouldn't recommend it to do what you are trying to accomplish.

Besides, testing "components in isolation" is unit testing, and from my experience this is not a best practice for Coded UI Test at all.

Coded UI test will help you in testing cross-application processes from end to end, closest to the user as it gets since its simulating the users inputs though keystrokes and mouse clicks.

Also, as UI tends to change quite a lot during development, and Coded UI relies on that, I suggest you use it mainly for regression testing for windows you know that are not going to change anytime soon. This way you'll keep you maintainance low and productivity high.

Hope this helps.

Coded UI is intended for checking the functionality of applications (and also of web pages). Coded UI is not for testing fragments of UI separate from their application. However, it would be possible to create a test harness application that contained one or more UI components allowing them to be tested in isolation from the real application.

A test harness could easily have a window for each component being tested. The window would include the component being tested plus a some other simple controls. These simple controls could expose internal values of the component being tested and also be used to pass values into the component.

I think what your attempting to do is viable, however ONLY for your own custom controls. I think you should tackle this in this order.

  1. A second instance of VS to capture what it actually sees about your control when your test spawns your control.
  2. Update your search criteria, eg process name, window title
  3. Potentially add properties to your TestInitialize spawner so it creates your control with useful ID's, names, or titles. (not sure which tech stack your control is in)
  4. Run tests again

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