/// <summary>
        /// The prepare reporting.
        /// </summary>
        /// <param name="executionObject">
        /// The execution object.
        /// </param>
        /// <param name="testSuite">
        /// The test suite.
        /// </param>
        /// <returns>
        /// The <see cref="bool"/>.
        /// </returns>
        public static bool PrepareReporting(ExecutionObject executionObject, string testSuite)
        {
            Log.Enter(LogInfo.Namespace(MethodBase.GetCurrentMethod()), MethodBase.GetCurrentMethod().Name);

            if (!Directory.Exists(executionObject.ReportFolderOverview + @"\Temp"))
            {
                Directory.CreateDirectory(executionObject.ReportFolderOverview + @"\Temp");
            }

            TestReport.Setup(ReportLevel.Debug, executionObject.ReportPathAndFileOverviewTemp, true);
            TestReport.BeginTestSuite(testSuite, executionObject.DtmStudioTestData.DeviceTypeProject.FDTDeviceTypeName);
            TestReport.BeginTestCase(testSuite, string.Empty);
            TestReport.BeginTestModule("Details");

            return(true);
        }
Example #2
0
        public static int Main(string[] args)
        {
            // Uncomment the following 2 lines if you want to automate Windows apps
            // by starting the test executable directly
            //if (Util.IsRestartRequiredForWinAppAccess)
            //    return Util.RestartWithUiAccess();

            Keyboard.AbortKey = System.Windows.Forms.Keys.Pause;

            // General speed settings, will not affect replay of individual modules
            Mouse.DefaultMoveTime        = 0;
            Keyboard.DefaultKeyPressTime = 20;
            Delay.SpeedFactor            = 0;

            TestReport.BeginTestSuite("SingleARDconfigTest");

            var flowExecutor = new FlowExecuter();

            flowExecutor.Run(new Flow1());
            flowExecutor.Run(new Flow2());

            return((flowExecutor.overallResult == TestResult.Passed) ? 1 : 0);
        }
Example #3
0
        /// <summary>
        /// Performs the playback of actions in this module.
        /// </summary>
        /// <remarks>You should not call this method directly, instead pass the module
        /// instance to the <see cref="TestModuleRunner.Run(ITestModule)"/> method
        /// that will in turn invoke this method.</remarks>
        void ITestModule.Run()
        {
            Mouse.DefaultMoveTime        = 300;
            Keyboard.DefaultKeyPressTime = 100;
            Delay.SpeedFactor            = 1.0;
            try
            {
                String _strPathRegionalWorkFlowSheet = filePath + "\\TestData\\BindingAuthority_Testdata.xlsx";
                //Ranorex.Controls.ProgressForm.Hide();
                //Read Driver Data sheet

                //TestDataFilePath = GetSheetPath(strEntityName);
                string timestamp = System.DateTime.Now.ToString("yyyyMMdd") + "_" + System.DateTime.Now.ToString("hhmmss");

                //Report Enviornment Setup
                ReportClass.ReportSetup("BindingAuthority", ResultFolderPath, timestamp);

                //Read Driver Data sheet
                DataTable dt = DataReader.ReadMyExcel(_strPathRegionalWorkFlowSheet, "Driver_BindingAuthority");
                //DataReader.EmptyReRun(TestDataFilePath,"Driver_BindingAuth$");

                //Read each Row in Driver_Project
                foreach (DataRow dr in dt.Rows)
                {
                    Dictionary <string, string> drDriverData = DataReader.LoadData(dr);

                    //Read Row needs to be executed TestCaseName
                    if (drDriverData["Execute"] == "Y")
                    {
                        //--------------------------Test Suite Start
                        TestReport.BeginTestSuite("Binding Authority", "Comment");
                        //--------------------------Start Test Case
//						TestReport.BeginTestCase(drDriverData["TestCaseNo"] +" - " + drDriverData["TestCaseName"]);
                        DataTable dtTestData = new DataTable();

                        //Read Rows from Test Data Sheet and get Test Script row count
                        dtTestData = DataReader.ReadMyExcel(_strPathRegionalWorkFlowSheet, drDriverData["DataSheet"]);
                        DataRow[] filteredRows = dtTestData.Select("TestCaseName='" + drDriverData["TestCaseName"] + "'");
                        foreach (DataRow testdatadr in filteredRows)
                        {
                            Dictionary <string, string> drTestData = DataReader.LoadData(testdatadr);
                            int iterationcount = Int32.Parse(drTestData["Iteration"]);
                            int itcount        = 1;
                            if (iterationcount > 1)
                            {
//								String test="Testing";
//								ActivityExecType act= ActivityExecType.RunIteration;
//								TestEntryActivityType tactivty=TestEntryActivityType.TestCase;
                                for (int j = 1; j <= iterationcount; j++)
                                {
                                    //ReportClass.errorValue = 0;

//									TestReport.BeginTestContainer(itcount,test,act,tactivty);
//									TestReport.BeginTestCase(drTestData["TestCaseName"],test);
                                    //TestReport.
                                    TestReport.BeginTestModule(drDriverData["TestCaseName"]);
                                    TestModuleRunner.Run(callTestCase(drDriverData["TestCaseName"], drTestData));
                                    TestReport.EndTestModule();
                                    //	TestReport.EndTestEntryContainer();
//									TestReport.EndTestCase();
                                    itcount++;
                                }
                            }
                            else
                            {
                                if (iterationcount == 1)
                                {
                                    //ReportClass.errorValue = 0;
                                    TestReport.BeginTestModule(drDriverData["TestCaseName"]);
                                    TestModuleRunner.Run(callTestCase(drDriverData["TestCaseName"], drTestData));
//									TestReport.EndTestModule();
//									if(reRun)
//										DataReader.UpdateExcelFile(TestDataFilePath,"Driver_RegionalWorkflow","TestCaseName",drDriverData["TestCaseName"],"ReRun","Y");
                                }
                            }
                        }
                        //End Test Case
//						TestReport.EndTestCase();
                    }
                }

//				//Read each Row in Driver_Project
//				foreach (DataRow dr in dt.Rows)
//				{
//					Dictionary<string,string> drDriverData= DataReader.LoadData(dr);
//
//					//Read Row needs to be executed TestCaseName
//					if(drDriverData["ReRun"]=="Y")
//					{
//						//--------------------------Test Suite Start
//						TestReport.BeginTestSuite("Regional WorkFlow","Comment");
//						//--------------------------Start Test Case
//						TestReport.BeginTestCase(drDriverData["TestCaseName"]);
//						DataTable dtTestData = new DataTable();
//
//						//Read Rows from Test Data Sheet and get Test Script row count
//						dtTestData= DataReader.ReadMyExcel(_strPathRegionalWorkFlowSheet,drDriverData["DataSheet"]);
//						DataRow[] filteredRows =  dtTestData.Select("TestCaseName='"+drDriverData["TestCaseName"]+"'");
//						foreach (DataRow testdatadr in filteredRows)
//						{
//							Dictionary<string,string> drTestData = DataReader.LoadData(testdatadr);
//							TestReport.BeginTestModule(drDriverData["TestCaseName"]);
//							TestModuleRunner.Run(ApplicationFunctions.callTestCase(drDriverData["TestCaseName"],drTestData));
//							TestReport.EndTestModule();
//						}
//						//End Test Case
//						TestReport.EndTestCase();
//					}
//				}
            }
            catch (Exception ex)
            {
                Report.Failure("Exception Occured :", ex.Message);
            }
        }
Example #4
0
 /// <summary>
 /// Begins the test suite.
 /// </summary>
 /// <param name="testSuiteName">Name of the test suite.</param>
 public static void BeginTestSuite(string testSuiteName)
 {
     TestReport.BeginTestSuite(testSuiteName);
 }
Example #5
0
        /// <summary>
        /// Performs the playback of actions in this module.
        /// </summary>
        /// <remarks>You should not call this method directly, instead pass the module
        /// instance to the <see cref="TestModuleRunner.Run(ITestModule)"/> method
        /// that will in turn invoke this method.</remarks>
        void ITestModule.Run()
        {
            Mouse.DefaultMoveTime        = 300;
            Keyboard.DefaultKeyPressTime = 100;
            Delay.SpeedFactor            = 1.0;
            try
            {
                string testCaseName;

                string timestamp = System.DateTime.Now.ToString("yyyyMMdd") + "_" + System.DateTime.Now.ToString("hhmmss");

                //Read Driver Data sheet
                DataTable dt         = DataReader.ReadMyExcel(TestDataFilePath, "Driver_RanorexDemo");
                DataTable dtTestData = new DataTable();
                //Report Envirnment Setup
                ReportClass.ReportSetup("RanorexDemo", ResultFolderPath, timestamp);
                Ranorex.Controls.ProgressForm.Show();
                if (envDetails == "")
                {
                    //Read each Row in Driver_ClaimsCenter
                    foreach (DataRow dr in dt.Rows)
                    {
                        Dictionary <string, string> drDriverData = DataReader.LoadData(dr);

                        //Read Row needs to be executed
                        if (drDriverData["Execute"] == "Y")
                        {
                            testCaseName = drDriverData["TestCaseName"];
                            //--------------------------Test Suite Start
                            TestReport.BeginTestSuite("Ranorex Demo", "Comment");
                            //--------------------------Start Test Case
                            TestReport.BeginTestCaseContainer(testCaseName);
                            int iterationcount = Int32.Parse(drDriverData["Iteration"]);
                            int itcount        = 1;

                            //Read Rows from Test Data Sheet and get Test Script row count
                            dtTestData = DataReader.ReadMyExcel(TestDataFilePath, drDriverData["DataSheet"]);
                            DataRow[] filteredRows = dtTestData.Select("TestCaseNo='" + drDriverData["TestCaseNo"] + "'");
                            Dictionary <string, string> drTestData = DataReader.LoadData(filteredRows[0]);
                            //------------------------------Start individual Script iteration
                            if (iterationcount > 1)
                            {
                                String                test     = "Testing";
                                ActivityExecType      act      = ActivityExecType.RunIteration;
                                TestEntryActivityType tactivty = TestEntryActivityType.TestCase;
                                for (int j = 1; j <= iterationcount; j++)
                                {
                                    TestReport.BeginTestEntryContainer(j, test, act, tactivty);
//										(drDriverData["TestCaseName"],j,test,act,tactivty);
                                    TestReport.BeginTestModule(testCaseName);
                                    TestModuleRunner.Run(callTestCase(drDriverData["TestCaseName"], drTestData));
                                    TestReport.EndTestModule();
                                    TestReport.EndTestEntryIterationContainer();
                                    itcount++;
                                }
                            }
                            else
                            {
                                if (iterationcount == 1)
                                {
                                    TestReport.BeginTestModule(testCaseName);
                                    TestModuleRunner.Run(callTestCase(drDriverData["TestCaseName"], drTestData));
                                    TestReport.EndTestModule();
                                }
                            }
                            //End Test Case
                            TestReport.EndTestCaseContainer();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                Report.Failure(ex.Message);
            }
        }
Example #6
0
        /// <summary>
        /// The prepare reporting.
        /// </summary>
        /// <param name="executionObject">
        /// The execution object.
        /// </param>
        /// <returns>
        /// The <see cref="string"/>.
        /// </returns>
        public static string PrepareReporting(ref ExecutionObject executionObject)
        {
            Log.Enter(LogInfo.Namespace(MethodBase.GetCurrentMethod()), MethodBase.GetCurrentMethod().Name);
            if (!Directory.Exists(executionObject.ReportFolderTestCases))
            {
                Directory.CreateDirectory(executionObject.ReportFolderTestCases);
            }

            var currentDateAndTime = DateTime.Now.ToString("yyyyMMdd_HHmmss");

            // currentTestCase contains the current testcase namen + date-time-stamp
            currentTestCase = currentDateAndTime + "_" + executionObject.TestCaseName;

            // filename contains the whole path
            // it´s number of characters must be less then 255-5 (5 from .data by creating the file)
            var fileName            = executionObject.ReportFolderTestCases + @"\" + currentTestCase;
            var testCasePathAndFile = fileName + executionObject.FileExtension; // originFileName;

            // check path length of all parts
            // Check path length for creating ranorex report
            // if ranorexReportLength > 92
            //   shorten name of ranorex report
            //   log info about shortening ranorexReport
            // if completePathLength > 250
            //   shorten name of ranorex report
            //   log info about shortening ranorexReport
            // if shortenig is not enought
            //   log info about ranorexReport which wont be available due path length issues
            try
            {
                string testSuiteName = executionObject.CurrentTestReportInfo.TestSuiteName;

                // Check currentTestCase length if filename is too long for ranorex setup function.
                // If filename is too long, cut of characters for valid number of characters.
                int currentTestCaseLength = currentTestCase.Length;
                if (currentTestCaseLength > ConstLenghts.MaxFileLengthByRanorex)
                {
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine("TestCaseName [" + currentTestCase + "] has more than " + ConstLenghts.MaxFileLengthByRanorex + " (" + currentTestCaseLength.ToString(CultureInfo.InvariantCulture) + ") characters and has been reduced to a valid length.");
                    Console.ResetColor();

                    currentTestCase       = currentTestCase.Remove(ConstLenghts.MaxFileLengthByRanorex, currentTestCaseLength - ConstLenghts.MaxFileLengthByRanorex);
                    testCasePathAndFile   = executionObject.ReportFolderTestCases + @"\" + currentTestCase + executionObject.FileExtension;
                    currentTestCaseLength = currentTestCase.Length;
                }

                // Check reportFileName length if path is too long for file system.
                // If filename is too long and if it is possible to cut of characters from currentTestCase filename
                // cut of characters for valid number of characters.
                int reportFileNameLength = testCasePathAndFile.Length;

                if (reportFileNameLength > ConstLenghts.MaxPathLengthForTempararyPostfix)
                {
                    Console.ForegroundColor = ConsoleColor.Cyan;
                    Console.WriteLine("ReportFileName [" + testCasePathAndFile + "] has more than " + (ConstLenghts.MaxPathLengthByOperatingSystem - 1) + " (" + testCasePathAndFile.Length + ") characters.");
                    Console.ResetColor();

                    int availableCharacters = ConstLenghts.MaxPathLengthForTempararyPostfix - reportFileNameLength + currentTestCaseLength;

                    // Shorten currentTestCase name to the length of available characters
                    if (availableCharacters - DateTimeLength - executionObject.FileExtension.Length > 0)
                    {
                        currentTestCase      = currentTestCase.Remove(availableCharacters, currentTestCaseLength - availableCharacters);
                        testCasePathAndFile  = executionObject.ReportFolderTestCases + @"\" + currentTestCase + executionObject.FileExtension;
                        reportFileNameLength = testCasePathAndFile.Length;
                    }
                    else
                    {
                        Console.ForegroundColor = ConsoleColor.Cyan;
                        Console.WriteLine("ReportFileName [" + testCasePathAndFile + "] could not be trimmed. There are less characters left for a filename with a length of one character + file extension.");
                        Console.ResetColor();
                    }
                }

                if (reportFileNameLength > ConstLenghts.MaxPathLengthForTempararyPostfix)
                {
                    // Create Report Object
                    executionObject.CurrentTestCaseInfo.TestCaseName   = currentTestCase + ": The TestCaseReport [" + currentTestCase + "] is not available due to exceeded path length = " + testCasePathAndFile.Length.ToString(CultureInfo.InvariantCulture) + ".";
                    executionObject.CurrentTestCaseInfo.TestCasePath   = string.Empty;
                    executionObject.CurrentTestCaseInfo.TestCaseResult = TestResult.Failed;
                    executionObject.CurrentTestReportInfo.TestCaseInfos.Add(executionObject.CurrentTestCaseInfo);
                }
                else
                {
                    TestReport.Setup(ReportLevel.Debug, testCasePathAndFile, true);
                    TestReport.BeginTestSuite(executionObject.CurrentTestCase.DisplayName, testSuiteName);
                    TestReport.BeginTestCase(executionObject.CurrentTestCase.DisplayName);
                    TestReport.BeginTestModule("Details");

                    string backToOverview = FileNameHandler.GetRelativePathToOverview(executionObject.ReportFolderOverview, executionObject.ReportFolderTestCases);
                    backToOverview = backToOverview + @"\" + executionObject.ReportNameOverview;

                    Report.LogHtml(ReportLevel.Debug, string.Empty, @"<a href='" + backToOverview + "'>" + @"Back to Overview" + "</a>");
                }
            }
            catch (Exception exception)
            {
                Log.Enter(LogInfo.Namespace(MethodBase.GetCurrentMethod()), exception.Message);
                Console.ForegroundColor = ConsoleColor.Cyan;
                Console.WriteLine(LogInfo.Namespace(MethodBase.GetCurrentMethod()) + ": " + exception.Message);
                Console.ResetColor();
            }

            return(testCasePathAndFile);
        }