public void RunStarted(string name, int testCount) { SAFEBBALog.Info(CommonUtilities.GetClassAndMethodName()); failedTestCasesToReRun += ConfigParameters.PATH_NUNIT_PACKAGE_CONSOLE_EXE; SAFEBBALog.TotalNumberOfTestsToRun = testCount; SAFEBBALog.PrintApplicationConfigurations(); }
/// <summary> /// Kill a pocess given the name of the process /// The process is killed if the pocess is longer than 3 seconds /// </summary> /// <param name="nameOfProcessToKill"></param> public static void killProcessByNames(string nameOfProcessToKill) { SAFEBBALog.Debug(CommonUtilities.GetClassAndMethodName(), nameOfProcessToKill); string[] nameOfProcessToKillList = nameOfProcessToKill.Split(','); foreach (string nameOfProcess in nameOfProcessToKillList) { try { foreach (Process proc in Process.GetProcessesByName(nameOfProcess)) { DateTime procStartTime = proc.StartTime; DateTime dateNow = DateTime.Now; long diff = (long)(dateNow - procStartTime).TotalMilliseconds; //Kill the process if longer than 3 secunds if (diff > 3000 && !(proc.ProcessName.ToLower().Contains("excel"))) { proc.Refresh(); proc.Kill(); } if (proc.ProcessName.ToLower().Contains("excel") && diff < 3000) { proc.Refresh(); proc.Kill(); } } } catch (Exception e) { SAFEBBALog.Warning("The process, " + nameOfProcessToKill + " could not be killed. See Exception: \n" + e); } Thread.Sleep(1000); } }
public void SuiteFinished(TestResult result) { SAFEBBALog.Info(CommonUtilities.GetClassAndMethodName()); if (SAFEBBALog.NumberOfExecutedTests == 0 && !isScreenShotTaken) { CreatScreenShotOnFailure(result); } }
/// <summary> /// Create a screen shot when a test case fail /// The screen shot is saved in /// </summary> /// <param name="result"></param> private void CreatScreenShotOnFailure(TestResult result) { SAFEBBALog.Info(CommonUtilities.GetClassAndMethodName()); SAFEBBALog.IsPreviousTestCaseSucceeded = true; string fullname = result.FullName; if (result.ResultState == ResultState.Error || result.ResultState == ResultState.Failure) { string testCaseName = result.Name; string fullNameWithoutTestCaseName = fullname.Substring(0, (fullname.Length - testCaseName.Length - 1)); int startIndexForTestClass = fullNameWithoutTestCaseName.LastIndexOf("."); string testClassName = fullNameWithoutTestCaseName.Substring(startIndexForTestClass + 1); string fullFolderPath = CommonUtilities.CreateFolder("bin\\Debug\\ScreenShots\\" + testClassName); string imageFullPathAndName = fullFolderPath + "\\" + testCaseName + CommonUtilities.GetCurrentDate() + ".png"; CommonUtilities.CreateAndSaveScreenShot(imageFullPathAndName); isScreenShotTaken = true; SAFEBBALog.IsPreviousTestCaseSucceeded = false; failedTestCasesToReRun += fullname + ","; } }
/// <summary> /// Deletes all the files within the specified folder /// </summary> /// <param name="folder">The folder from which we wish to delete all of the files</param> public static void ClearFolder(DirectoryInfo folder) { SAFEBBALog.Debug(CommonUtilities.GetClassAndMethodName(), folder.FullName); // Iterate each file foreach (FileInfo file in folder.GetFiles()) { try { // Delete the file, ignoring any exceptions file.Delete(); } catch (Exception) { } } // For each folder in the specified folder foreach (DirectoryInfo subfolder in folder.GetDirectories()) { // Clear all the files in the folder ClearFolder(subfolder); } }
/// <summary> /// Clear the cache for Inernet Explorer /// </summary> public static void ClearIECache() { SAFEBBALog.Debug(CommonUtilities.GetClassAndMethodName()); // Clear the special cache folder ClearFolder(new DirectoryInfo(Environment.GetFolderPath(Environment.SpecialFolder.InternetCache))); }
public void TestStarted(TestName testName) { SAFEBBALog.Info(CommonUtilities.GetClassAndMethodName()); }
public void SuiteStarted(TestName testName) { SAFEBBALog.Info(CommonUtilities.GetClassAndMethodName()); isScreenShotTaken = false; }
public void RunFinished(TestResult result) { SAFEBBALog.Info(CommonUtilities.GetClassAndMethodName()); createReRunFailesTestCaseFile(); }
public void RunFinished(Exception exception) { SAFEBBALog.Info(CommonUtilities.GetClassAndMethodName()); }
public void TestFinished(TestResult result) { SAFEBBALog.Info(CommonUtilities.GetClassAndMethodName()); CreatScreenShotOnFailure(result); SAFEBBALog.TestCaseEnd(result); }