locked
Reference to AUT (application under test) from Coded UI Test RRS feed

  • Question

  • In my WPF app, I have databound some controls to a collection and based on how fast items are added to the collection, some of the controls in the app change visual appearances (background color, size, etc.). Data for the collection is coming from external sensors.

    I don’t have access to the sensors in the test environment, so I have to simulate the incoming data. Now my question is, how I from a Coded UI Test can get a handle to the AUT so I programmatically can add and remove items from the collection, and thereby simulate incoming data from the sensors.

    Wednesday, November 14, 2012 8:08 AM

Answers

  • I still think using one of the mocking frameworks mentioned in the above link is your best bet.  If you own the AUT code you could certainly refactor and  use interfaces and dependency inversion (or injection) then write your own test assemblies to replace the AUT but if things weren't designed with interfaces and dependency inversion in mind that is likely a large change.

    Tim

    Monday, November 26, 2012 11:50 PM

All replies

  • If you are using vs 2012 ultimate I suggest looking at stubs and shims: http://msdn.microsoft.com/en-us/library/hh549175.aspx  Which one you use depends on the AUT api.  Does it adhere to an interface and can you inject it (usually via constructor).  If so use a stub, if not, try a shim which basically will intercept the call to the AUT at runtime and rediect the calls to your shim.

    If you are not using 2012 ultimate, consider a mocking framework http://stackoverflow.com/questions/37359/what-c-sharp-mocking-framework-to-use

    Again, chosing wich framework depends on the "shape" of the AUT and whether or not interfaces were used.

    programming to an interface rather than an implementation really makes testing code easier and is one of my highest priority design principles.

    hope that helps 


    Tim

    Wednesday, November 14, 2012 5:02 PM
  • Hi Tim, thank's for your reply. Unfortunately, I use VS2012 Premium and will not be able to use Fakes, that's why I'm looking for a solution where I can get a referance to AUT from within my Coded UI Test.
    Friday, November 16, 2012 6:42 AM
  • Hi Tim,

    Thank you for your friendly assistance.

    Hi A. Ryborg,

    I am trying to involve someone familiar with this topic to further look at this issue. There might be some time delay. Appreciate your patience.

    Have a nice weekend,


    Jack Zhai [MSFT]
    MSDN Community Support | Feedback to us

    Friday, November 16, 2012 7:31 AM
    Moderator
  • From a support perspective this is really beyond what we can do here in the forums. If you cannot determine your answer here or on your own, consider opening a support case with us. Visit this link to see the various support options that are available to better meet your needs:  http://support.microsoft.com/default.aspx?id=fh;en-us;offerprophone.

    Thank you

    Monday, November 26, 2012 10:28 PM
    Moderator
  • I still think using one of the mocking frameworks mentioned in the above link is your best bet.  If you own the AUT code you could certainly refactor and  use interfaces and dependency inversion (or injection) then write your own test assemblies to replace the AUT but if things weren't designed with interfaces and dependency inversion in mind that is likely a large change.

    Tim

    Monday, November 26, 2012 11:50 PM