Esempio n. 1
0
        /// <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 + ",";
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Create a file that contains the commandline in order to be able rerun the failed test cases
        /// </summary>
        private void createReRunFailesTestCaseFile()
        {
            string projectName = System.Reflection.Assembly.GetExecutingAssembly().GetName().Name;
            string p           = " " + projectName + ConfigParameters.PATH_SAF_DLL_BIN_DEBUG + projectName + ".dll";

            failedTestCasesToReRun += p;
            failedTestCasesToReRun  = failedTestCasesToReRun.Replace("\\", @"\");
            string reRunFialdTestCasesFolderPath = ConfigParameters.PATH_RERUN_FAILED_TEST_CASES_FOLDER + ConfigParameters.ENVIRONMENT;
            bool   exists = Directory.Exists(reRunFialdTestCasesFolderPath);

            if (!exists)
            {
                System.IO.Directory.CreateDirectory(reRunFialdTestCasesFolderPath);
            }
            File.WriteAllText(reRunFialdTestCasesFolderPath + @"\ReRunFailedTestCases" + CommonUtilities.GetCurrentDate() + ".bat", failedTestCasesToReRun);
            File.WriteAllText(reRunFialdTestCasesFolderPath + @"\ReRunFailedTestCases_Latest.bat", failedTestCasesToReRun);
        }