In a CodedUI Test, I am using System.Diagnostics.Process
(Process.Start(exePath);
) to execute a .exe file. Now my problem is, after Executing the test my application closes(WPF front-end). My question is, How will I get the process that I just started to independent from the thread where Process.Start()
is executing so that once I the Test has ran the exe keeps running. I want it to keep running because there are other UI Tests that need the Front end Running. (Starting the exe at the beginning of each tests is too expensive and slow)
I hope this is clear enough.
This is my code:
//[TestInitialize()] has already started the exe, so I have my front end open.
[TestMethod]
[TestCategory("Default Layout")]
static void Move_StartTimer_Button_To_The_Top_Right_Corner_Keeps_Keeps_Button_Even_After_App_Restarts()
{
Process myExe = Process.GetProcesses().FirstOrDefault(process => process.ProcessName == "MyAppName");
var fileName = myExe?.MainModule.FileName;
UIMap.Click_Close_Application();
Assert.IsTrue(Application_Closed_Sucessfully);
Process.Start(fileName);
Assert.IsTrue(Application_Layout_Has_Button_On_The_Top_Right_Corner);
}
When Move_StartTimer_Button_To_The_Top_Right_Corner_Keeps_Keeps_Button_Even_After_App_Restarts()
has executed and completed, my app closes as well. How do I keep the front end running even after the execution? PLEASE NOTE: This is a CodedUI Test code, so by "after execution" I mean after the Test has ran (it may pass or fail it doesn't matter as long as it does not close the front end).
Process.Start()
just starts a process - it doesn't ever stop a process. – Hereditarycmd
with argument/C path/to/firefox.exe
– Downstroke)
afterContains("firefox")
. Moreover, your question is still not clear. What do you mean by "Somewhere in between I close firefox before calling 'Process.Start()'"? – Horsemint