How to programmatically start a WPF application from a unit test?

Posted by Lernkurve on Stack Overflow See other posts from Stack Overflow or by Lernkurve
Published on 2010-03-04T10:40:58Z Indexed on 2010/03/08 23:51 UTC
Read the original article Hit count: 773

Filed under:
|
|
|

Problem

VS2010 and TFS2010 support creating so-called Coded UI Tests. All the demos I have found, start with the WPF application already running in the background when the Coded UI Test begins or the EXE is started using the absolute path to it.

I, however, would like to start my WPF application under test from the unit test code. That way it'll also work on the build server and on my peer's working copies.

How do I accomplish that?

My discoveries so far

a) This post shows how to start a XAML window. But that's not what I want. I want to start the App.xaml because it contains XAML resources and there is application logic in the code behind file.

b) The second screenshot on this post shows a line starting with

ApplicationUnterTest calculatorWindow = ApplicationUnderTest.Launch(...);

which is conceptually pretty much what I am looking for, except that again this example uses an absolute path the the executable file.

c) A Google search for "Programmatically start WPF" didn't help either.

© Stack Overflow or respective owner

Related posts about c#

Related posts about wpf