• 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);
    }
  • 相关阅读:
    十大编程算法助程序员走上高手之路
    软件流程图规范
    统一软件开发过程(rup)理解
    Java 数组基础
    软件开发生命周期模型 瀑布模型、增量模型、原型模型、螺旋模型、喷泉模型总结
    UML(5)——协作图
    时序图、活动图、状态图、协作图的区别
    面向对象分析设计-------02UML+UML各种图形及作用
    ExecutorService的十个使用技巧
    使用guava带来的方便
  • 原文地址:https://www.cnblogs.com/qixue/p/2232028.html
Copyright © 2020-2023  润新知