示例#1
0
        public void TestUploadFile()
        {
            // Catches exceptions thrown from any class or method
            try
            {
                // Navigates to a country's job vacancies, South Africa, in this case 
                CountrySelection.Execute();
                test.Pass("Country selection for available jobs successful");

                // Selects Job posts, only the first one in the list in this case 
                JobPostSelection.Execute();
                test.Pass("job post selection successful");

                // Implements the job application process of filling the application form
                // Retrieves user information from excel data sheet to fill the application
                JobApplication.Execute(TestCaseRow);
                test.Pass("job application successful");

                // Validates whether the test case passes or fails based on the error message returned
                Validation.Execute();

                // Passes or fails the test from the set test result value
                // test result value is insert or updated in the excel data sheet
                if (BaseClass.TestResult == true)
                {
                    // If the value of test results is True, then test is complete - pass 
                    ExcelDataIO.WriteData("Pass", TestCaseRow, Constant.COLUMN_RESULT);
                }
                else
                {
                    // If the value of test results is False, then test is complete - fail 
                    // Throws exception in case of a fail, caught by catch block below
                    throw new Exception("Test Case Failed - Validation failed");
                }
            }
            catch (Exception e)
            {
                // If in case you got any exception during the test, it will mark your test as Fail in the test result sheet
                ExcelDataIO.WriteData("Fail", TestCaseRow, Constant.COLUMN_RESULT);
                // This will print the error log message
                Log.Error(e.Message);
                test.Log(Status.Error, e.Message);

                // Exception to fail the test completely in the NUnit results
                throw e;
            }
        }