MyTestInitialize allows you to run some code before the test starts, from MyTestInitialize i call my process kill.
public void MyTestInitialize()
{
// To generate code for this test, select "Generate Code for Coded UI Test" from the shortcut menu and select one of the menu items.
// For more information on generated code, see http://go.microsoft.com/fwlink/?LinkId=179463
TerminateProcess.YerOuttaHere();
}
The kill process uses System.Diagnostics and kills any notepad process.
using System;
using System.Threading;
using System.Diagnostics;
public class TerminateProcess
{
public static void YerOuttaHere()
{
Process[] processes = Process.GetProcessesByName("notepad");
foreach (Process process in processes)
{
process.Kill();
process.WaitForExit();
}
}
}
No comments:
Post a Comment