I often write small, self continained unit tests that check the behaviour of custom controls. Typically I want to instatiate the control, interact with it in some minimal way, then check some condition has been met. Quick to write, orthogonal, minimal auxilliary
support classes, that's what I'm looking for.
However, reading thorough the documentation I'm struggling to replicate this type of test in White that doesn't seem a bit unwieldy and overcomplicated. So to write test to test a custom control "TestWidget" I'm currently thinking I'd have to do the
- Create a new test application, which instantiates a window, which instantiates "TestWidget" (remembering to instrument these up with Automation ID's)
- From my Test code instantiate the test app using Application.Launch
- Get the window using Application.GetWindow
- Get the TestWidget UIItem using Window.Get
- Then go ahead to actually interact with the UIItem etc
My question is why can't I just instantiate the TestWidget directly in the test function and get the UIItem directly from it? Instantiation of a whole application and a window, then navigating back to down to the control I care about seems a bit surplus
Apologies if I'm asking a boneheaded question here and missing the point in some way, but whilst I can see there is absolultely a great use case for testing objects in-situ in a real-life application, for a large percentage of the time I'm wanting to write
small, low-level tests in controlled, minimal environents. In the interests of parsimony, I'd like to avoid unneccesary setup in these cases.
did you use UIAutomation for your quick tests?
My understanding is, that UIAutomation does not work this way. White is "only" a framework for UIAutomation.
Your question is a general design question and might be answered in Microsoft UIAutomation Forum.
My understanding of UIAutomation is: UIAutomation is something like Client/Server.
The application under test is the server, and your test is the client,
and only the informations the server allow to see can be seen by your test or in some cases can be manipulate by the test, for example text boxe.
or something else.
The test does not know anything about the internal structure of the application and knows only the visual tree.
So UIautomation and White are black box tests tools.