Exemple #1
0
        public TestCase Parse(string filepath, int testcaseId)
        {
            /*
             * Load doc
             * Get the table
             * Get the row and get the description and expected result
             * Generate height per WordParagraph for Description
             * Attempt to join the Description and Expected
             */

            var doc = ap.Documents.Open(filepath);

            this.doc = doc;
            Thread.Sleep(500); // Word needs to load the document and there is no way of doing a waitfor.

            var testcase = new TestCase
            {
                Id = testcaseId
            };

            Globals.Log("Total word paragraphs found : " + doc.Paragraphs.Count);

            var tables        = doc.Tables.Cast <Table>().ToList();
            var allParagraphs = doc.Paragraphs.Cast <Paragraph>().ToList();

            testcase.AddTitle(allParagraphs);
            testcase.AddDescription(allParagraphs);
            testcase.AddTestSteps(tables);
            doc.Close();

            return(testcase);
        }
Exemple #2
0
        public TestCase ParseSpecificTable(string filepath, int tableIndex)
        {
            var doc = ap.Documents.Open(filepath);

            this.doc = doc;
            Console.WriteLine(doc.Tables.Count);
            Thread.Sleep(500); // Word needs to load the document and there is no way of doing a waitfor.
            Console.WriteLine(doc.Tables.Count);

            var rawList = doc.Tables.Cast <Table>().ToList();
            var passIn  = new List <Table>()
            {
                rawList[tableIndex]
            };

            var testcase = new TestCase();

            testcase.AddTestSteps(passIn);

            return(testcase);
        }
Exemple #3
0
        public static TestCase ExecuteTestMethod(MethodInfo testMethod, Status suiteStatus, object suiteInstance, int index, object[] paras = null, TestCase testCase = null)
        {
            if (testCase == null)
            {
                testCase = CreateTestCase(testMethod, suiteStatus, index);
            }

            Logger.LogMsg(Severity.INFO, $"Test case: {testMethod.Name} started at: {DateTime.Now}");
            object testReturn = null;

            try
            {
                StepProxy.InitiateTestExecution(testCase.Status);
                testReturn = testMethod.Invoke(suiteInstance, paras);
            }
            catch (Exception ex)
            {
                testCase.SetStatus(Status.Failed);
                Logger.LogMsg(Severity.ERROR, $"Runner exception: {ex.GetLastInnerException().Message}. StackTrace: {ex.GetLastInnerException().StackTrace}");
                testCase.SetError($"Runner exception: {ex.GetLastInnerException().Message}. StackTrace: {ex.GetLastInnerException().StackTrace}");
            }

            testCase.SetValue(testReturn);
            testCase.AddTestSteps(StepProxy.TestSteps);
            StepProxy.CompleteTestExecution();
            if (testCase.Status == Status.Undefined)
            {
                testCase.SetStatus(DetermineTestCaseStatus(testCase));
            }

            testCase.Finish();
            Logger.LogMsg(Severity.INFO, $"Test case: {testCase.Name} => Status is: {testCase.Status}...");
            Logger.LogMsg(Severity.INFO, $"Test case: {testMethod.Name} completed at: {DateTime.Now}...");

            return(testCase);
        }