zoukankan      html  css  js  c++  java
  • Auto Test: Test Case Structure

    最近在使用的一些Test Case 的逻辑结构:

    接口:

        interface ITestCase
        {
            string CaseID { getset; }
            string CaseTitle { getset; }
            bool Passed { getset; }
            void ExcuteTC(string xmlFilePath, string infFilePath);        
            bool VerifyPass(string xmlFilePath, string infFilePath);
        }

    Sample of Test Case:

    class TestCase_1 : ITestCase
        {

            public string CaseID
            {
                get
                {
                    return "1&10";
                }
                set
                {
                    throw new NotImplementedException();
                }
            }

            public string CaseTitle
            {
                get
                {
                    return "INF: Review Disk: Opening screens are presented in the correct order";
                }
                set
                {
                    throw new NotImplementedException();
                }
            }
            public bool Passed { getset; }

            public string[] ActualSection { getset; }
            public string[][] ExpectedSection { getset; }

            public TestCase_1()
            {
               
            }

            public bool IsCorrectOrder(ExamClass exam, ExcelHelper excel, int lanugage)
            {
                bool isPass = true;

                return isPass;
            }
            public bool VerifyPass(string xmlFilePath, string infFilePath)
            {
                XmlDocument xmlDoc = XmlHelper.CreateXMLDocumentObject(xmlFilePath);
                
                ExamClass exam = ExamHelper.CreateExam(xmlDoc);

                ExcelHelper excelHelper = new ExcelHelper(infFilePath);

                //string welcomeTime = excelHelper.ReturnWelcomeTime();
                
    //string ndaTime = excelHelper.ReturnNDATime();
                
    //string conditionalItemTime = excelHelper.ReturnConditionalItemTime();
                string surveyTime = excelHelper.ReturnSurveyTime();
                //string examTime = excelHelper.ReturnExamTime();
                
    //string commentTime = excelHelper.ReturnCommentTime();
                
    //string reportTime = excelHelper.ReturnReportTime();

        
    //Logical Code...
             
                return true;
            }

            public void ExcuteTC(string xmlFilePath, string infFilePath)
            {
                Passed = VerifyPass(xmlFilePath, infFilePath);
            }
        }

    返回每一条Case的实例:

        class TestCaseHelper
        {
            public ITestCase FactoryTestCase(int i)
            {
                ITestCase tc = null;
                switch (i)
                {
                    case 1: tc = new TestCase_1(); break;
                    case 2: tc = new TestCase_2(); break;
                    case 3: tc = new TestCase_3(); break;
                    case 4: tc = new TestCase_4(); break;                
                    case 1001: tc = new TestCase_1001(); break;
                    case 1002: tc = new TestCase_1002(); break;
                    case 1003: tc = new TestCase_1003(); break;
                    case 1004: tc = new TestCase_1004(); break;
                    case 1005: tc = new TestCase_1005(); break;
                    case 1006: tc = new TestCase_1006(); break;
                }
                return tc;
            }
        }

    循环执行每一条Case:

      ITestCase tc = null;
                for (int i = 1; i < 5; i++)
                {
                    tc = case_Helper.FactoryTestCase(i);
                    tc.ExcuteTC(xmlPath, excelPath);
    }
  • 相关阅读:
    手写vite
    单点登录的实现原理
    vue中和react中key的用法
    手写MVVM
    rtvue-lowcode:一款基于uniapp框架和uview组件库的开源低代码开发平台
    博图TIA中ModbusRTU_CRC校验程序的实现
    博图TIA中ModbusRTU Over TCP/IP通讯的实现
    webpack之file-loader和url-loader的区别
    Webpack中Loader和Plugin的区别?编写Loader,Plugin的思路?
    spark-sql 与hive 常用函数
  • 原文地址:https://www.cnblogs.com/qixue/p/2232028.html
Copyright © 2011-2022 走看看