Can I run Coded-UI Tests from Windows Froms Applications? Looking for a sample.
Thanks.
Can I run Coded-UI Tests from Windows Froms Applications? Looking for a sample.
Thanks.
Of course you can - you can use mstest.exe command line application for running Coded UI Tests. You just need to write simple algorithm ensuring that correct parameters will be passed while launching mstest. For reference go here
You should have a look at NUnitForms that is a extension to NUnit.
Your NUnit tests can open a window and interact with the controls. Your tests will automatically manipulate and verify the properties of the gui. NUnitForms takes care of cleaning up your forms between tests, detecting and handling modal dialog boxes, and verifying that your expectations for the test are fulfilled.
Reference here
see also
How to unit test winforms applications
Unit Test to verify that WinForms application doesn't load Assembly more than once
Basically you will better off separating your logic completely from the UI , making your UI as thin as possible, and testing the logic separately .
You can find solution here for console application. You have to add additional references in order to work test in windows forms application or other project(I had to add reference to Microsoft.VisualStudio.TestTools.UITest.WindowsStoreUtility
other than the listed refrences in the article). But as explained in this so answer it would be nice if you can use it in a project that is meant to use these assemblies.