Ejemplo n.º 1
0
        public void ExeTestCase <T>(T driver, ITestPropertyModelBase prop, List <Dictionary <string, string> > testElemList) where T : RemoteWebDriver
        {
            var  dbIo       = new DataBaseIo();
            int  fileNameNo = 0;    //ファイル名No
            bool result     = true; //テスト結果格納

            //テスト要素の実行
            foreach (Dictionary <string, string> tlist in testElemList)
            {
                //スクリーンショットの取得、エビデンスのファイル名のNoをカウントアップ
                if ((int)EnumTestElem.getScreen == Convert.ToInt32(tlist[FileIo.ELEM_NO]))
                {
                    result = this.TestElementExecution(driver, Convert.ToInt32(tlist[FileIo.ELEM_NO]), prop, fileNameNo.ToString("00"), "", tlist[FileIo.SLEEP_TIME]);
                    fileNameNo++;
                }
                //csvの取得
                else if ((int)EnumTestElem.Export_Csv == Convert.ToInt32(tlist[FileIo.ELEM_NO]))
                {
                    dbIo.ExportCsv2(prop.evidenceSavePath, fileNameNo.ToString("00"), tlist[FileIo.ELEM_NAME], tlist[FileIo.SEND_KEY]);
                }
                //その他画面要素の操作
                else
                {
                    result = this.TestElementExecution(driver, Convert.ToInt32(tlist[FileIo.ELEM_NO]), prop, tlist[FileIo.ELEM_NAME], tlist[FileIo.SEND_KEY], tlist[FileIo.SLEEP_TIME]);
                }

                if (!result)
                {
                    break;
                }
            }
        }
Ejemplo n.º 2
0
        public string insertTestCase(ITestCasePropertyModelBase testCase)
        {
            var dbIo = new DataBaseIo();

            //Create ヘッダ

            //すでに登録済みのprojectNoのテストケース件数を取得
            int projectCount = dbIo.ExeRecodeCount($"SELECT * FROM test_case_t WHERE test_case_no like '{ testCase.projectNo }%';");

            //新しい連番を取得
            string newSerial     = (projectCount + 1).ToString($"D{ ConfigurationManager.AppSettings["ProjectNoCountDigits"] }");
            string newTestCaseNo = $"{ testCase.projectNo }-{ newSerial }";

            //インサート文作成
            string insTestCase = "INSERT INTO test_case_t(test_case_no, name, test_url, description) VALUES ";

            //インサートするレコード作成
            insTestCase += $"('{ newTestCaseNo }', '{ testCase.testCaseName }', '{ testCase.testURL }', '{ testCase.testDescription }');";

            //Create ボディー

            //インサート文作成
            string insTestCaseDetail = "INSERT INTO test_case_detail_t(test_case_no, execute_order, elem_no, elem_name, sendkey, sleep_time) VALUES ";

            //インサートするレコード作成
            int index = 1;

            foreach (var tlist in testCase.testElemList)
            {
                insTestCaseDetail += $@"('{ newTestCaseNo }', 
                                        '{ index.ToString("00000") }', 
                                        '{ tlist[FileIo.ELEM_NO] }', 
                                        '{ tlist[FileIo.ELEM_NAME] }', 
                                        '{ tlist[FileIo.SEND_KEY] }', 
                                        '{ tlist[FileIo.SLEEP_TIME] }'),";
                index++;
            }

            //最後の不要な","を削除してセミコロンで閉じる
            insTestCaseDetail = insTestCaseDetail.Substring(0, insTestCaseDetail.Length - 1) + ";";

            //データベースにINSERTする
            int[] result = dbIo.ExeDml2(insTestCase, insTestCaseDetail);

            if (result[0] == 0 || result[1] == 0)
            {
                return($"テストケースのINSERTに失敗しました。Test case table Add:{ result[0] }件 Test case detail table Add:{ result[1] }件");
            }

            return($"テストケースのINSERTが完了しました。Test case table Add:{ result[0] }件 Test case detail table Add:{ result[1] }件");
        }
Ejemplo n.º 3
0
        public List <Dictionary <string, string> > TestCaseFromDB(string testCaseNo)
        {
            var testElemList = new List <Dictionary <string, string> >();
            List <TestCaseDetailModel> testCaseDetailList = new DataBaseIo().ExeReader <TestCaseDetailModel>($@"select * from test_case_detail_t where test_case_no = '{ testCaseNo }'");

            foreach (var list in testCaseDetailList)
            {
                //テストケースを格納する
                testElemList.Add(new Dictionary <string, string>()
                {
                    { FileIo.ELEM_NO, $"{ list.elem_no }" }, { FileIo.ELEM_NAME, $"{ list.elem_name }" }, { FileIo.SEND_KEY, $"{ list.sendkey }" }, { FileIo.SLEEP_TIME, $"{ list.sleep_time }" }
                });
            }

            return(testElemList);
        }
Ejemplo n.º 4
0
        public virtual void ExeTest <T>(T driver, ITestPropertyModelBase prop) where T : RemoteWebDriver
        {
            //テストケースの取得
            //カスタムテストケースから
            List <Dictionary <string, string> > testElemList = null;

            if (prop.testCase == "801")
            {
                testElemList = new TestCase01().TestElement(prop);
            }
            //CSVファイルから
            else if (prop.testCase == "901")
            {
                testElemList = new FileIo().TestCaseFromUploadFile(prop.uploadFileSavePath, prop.testCaseFile);
            }
            // データベースから
            else if (prop.testCase == "902")
            {
                var dbIo = new DataBaseIo();
                testElemList = dbIo.TestCaseFromDB(prop.selectTestCaseNo);
                List <TestCaseModel> testCaseList = dbIo.ExeReader <TestCaseModel>($@"select * from test_case_t where test_case_no = '{ prop.selectTestCaseNo }'");
                prop.testURL = testCaseList[0].test_url;
            }

            //ブラウザを開く
            driver.Navigate().GoToUrl(prop.testURL);

            //画面サイズ設定
            var so = new ScreenOprations();

            so.ReSize(driver, prop.screenWidth, prop.screenHeight);

            //テストケースの実行
            this.ExeTestCase <T>(driver, prop, testElemList);

            if (prop.screenCloseFlg)
            {
                //ブラウザを閉じる
                driver.Close();
            }
        }