Esempio n. 1
0
        private void button3_Click(object sender, EventArgs e)
        {
            if (!initTestcaseBox())
            {
                return;
            }

            Excel.Worksheet sheet = app.ActiveWorkbook.ActiveSheet as Excel.Worksheet;

            Excel.Range selection = app.Application.Selection as Excel.Range;
            DefaultTC   itc       = (DefaultTC)this.cbScriptType.SelectedItem;

            if (selection.Count != 1 || !itc.InitialTestcase(sheet, selection.Row))
            {
                this.AppendLine("请选择1行用例,并且测试步骤字段不能为空");
                return;
            }

            int           row = selection.Row;
            List <string> tmp = itc.getSteps();
            string        s   = "";

            for (int i = 0; i < tmp.Count; i++)
            {
                s += (i + 1) + "," + tmp[i] + "\n";
            }

            sheet.Cells[row, (int)DefaultTC.colName.STEP] = s.Trim();

            tmp = itc.getExpRsts();
            s   = "";
            for (int i = 0; i < tmp.Count; i++)
            {
                s += (i + 1) + "," + tmp[i] + "\n";
            }

            sheet.Cells[row, (int)DefaultTC.colName.EXP_RESULT] = s.Trim();
        }
Esempio n. 2
0
        public int addTestcases(Excel.Worksheet sheet,DefaultTC itc, int row)
        {
            itc.InitialTestcase(sheet, row);
               // testsuite ts=addItems(4,itc.GetCell(DefaultTC.colName.FEATUREID),itc.GetCell(DefaultTC.colName.FEATURE_DESC));

            string detail = itc.GetCell(DefaultTC.colName.FEATUREID)+":"+itc.GetCell(DefaultTC.colName.CASE_DESC);

            testsuite ts = addItems(4, itc.GetCell(DefaultTC.colName.FEATURE_DESC), detail);

            string preset = itc.GetCell(DefaultTC.colName.PRESET);
            List<string> steps = itc.getSteps();
            List<string> exp = itc.getExpRsts();
            string req = itc.GetCell(DefaultTC.colName.DS_ID);
            bool can_auto = itc.GetCell(DefaultTC.colName.CAN_AUTO).ToLower().Equals("true");
            string importance = itc.GetCell(DefaultTC.colName.PRIORITY).ToLower();
            string testtype=itc.GetCell(DefaultTC.colName.TYPE);

            uint order = 0;
            while (true)
            {
                row++;
                string c0 = itc.GetSubCase(row, DefaultTC.subColName.ID0);
                string c1 = itc.GetSubCase(row,DefaultTC.subColName.ID);

                if (c0.Length != 0||c1.Length==0)
                {
                    row--;
                    return row;
                }

                string c2 = itc.GetSubCase(row,DefaultTC.subColName.SAMPLES);
                testcase tc = new testcase();
                tc.name = c1;
                tc.externalid = externalid++;
                tc.internalid = externalid+"";
                tc.node_order = order++;
                tc.version = 1;
                tc.summary = c2;
                tc.preconditions = preset;
                tc.execution_type = (uint)(can_auto ? 2 : 1);
                if (importance.Length>5)
                    tc.importance = Convert.ToUInt32(importance.Substring(5,1));
                else tc.importance = 1;
                custom_field test_type=new custom_field();
                test_type.name="test_type";
                test_type.value=testtype;
                tc.custom_fields.Add(test_type);

                //todo 需求没有处理
                //string reqs= itc.GetSubCase(row,DefaultTC.subColName.REQ);
                //requirement rq=new requirement();

                //tc.requirements.Add

                for (int i = 0; i < steps.Count; i++) {
                    step s = new step();
                    s.actions = steps[i];
                    s.expectedresults=exp[i];
                    s.step_number=(uint)(i+1);
                    s.execution_type = tc.execution_type;
                    tc.steps.Add(s);
                }

                ts.Items.Add(tc);
            }
        }
Esempio n. 3
0
        private void bCheckStyle_Click(object sender, EventArgs e)
        {
            if (!initTestcaseBox())
            {
                return;
            }

            Excel.Worksheet sheet = app.ActiveWorkbook.ActiveSheet as Excel.Worksheet;
            try
            {
                int  rows      = sheet.UsedRange.Rows.Count;
                int  curr_flag = 0;
                bool isok      = true;
                for (int i = 3; i < rows; i++)
                {
                    Excel.Range tmprange = sheet.Range["A" + i, Type.Missing].EntireRow;
                    Array       values   = (Array)tmprange.Cells.Value2;
                    Object      c1       = values.GetValue(1, 1);
                    Object      c2       = values.GetValue(1, 2);
                    if (c1 == null)
                    {
                        if (c2 == null)
                        {
                            this.AppendLine("Warning:空白行,row " + i);
                            isok = false;
                            continue;
                        }
                        else
                        {
                            curr_flag = c2.ToString().Split(new string[] { "_" }, StringSplitOptions.None).Length;
                        }
                    }
                    if (c1 == null)
                    {
                        continue;
                    }

                    int flag = c1.ToString().Split(new string[] { "_" }, StringSplitOptions.None).Length;

                    if (flag > 5)
                    {
                        this.AppendLine("Warning:层级大过5,row " + i);
                        isok = false;

                        continue;
                    }

                    if (curr_flag <= 0)
                    {
                        curr_flag = flag;
                        continue;
                    }

                    if ((flag - curr_flag) > 1)
                    {
                        this.AppendLine("Warning:缺少中间模块,row " + i);
                        isok = false;
                    }

                    if (flag == 5)
                    {
                        if (curr_flag == 5)
                        {
                            this.AppendLine("Warning:没有生产用例 row " + (i - 1));
                            isok = false;
                        }
                        DefaultTC itc = (DefaultTC)this.cbScriptType.SelectedItem;
                        if (!itc.InitialTestcase(sheet, i))
                        {
                            isok = false;
                        }
                        else if (itc.getSteps().Count != itc.getExpRsts().Count)
                        {
                            this.AppendLine("Warning:步骤和预期结果长度不一致 row " + i);
                            isok = false;
                        }
                    }
                    curr_flag = flag;
                }
                if (isok)
                {
                    this.AppendLine("End!");
                }
            }
            catch (Exception ex)
            {
                this.AppendLine(ex.StackTrace);
            }
        }
Esempio n. 4
0
        public int addTestcases(Excel.Worksheet sheet, DefaultTC itc, int row)
        {
            itc.InitialTestcase(sheet, row);
            // testsuite ts=addItems(4,itc.GetCell(DefaultTC.colName.FEATUREID),itc.GetCell(DefaultTC.colName.FEATURE_DESC));

            string detail = itc.GetCell(DefaultTC.colName.FEATUREID) + ":" + itc.GetCell(DefaultTC.colName.CASE_DESC);

            testsuite ts = addItems(4, itc.GetCell(DefaultTC.colName.FEATURE_DESC), detail);

            string        preset     = itc.GetCell(DefaultTC.colName.PRESET);
            List <string> steps      = itc.getSteps();
            List <string> exp        = itc.getExpRsts();
            string        req        = itc.GetCell(DefaultTC.colName.DS_ID);
            bool          can_auto   = itc.GetCell(DefaultTC.colName.CAN_AUTO).ToLower().Equals("true");
            string        importance = itc.GetCell(DefaultTC.colName.PRIORITY).ToLower();
            string        testtype   = itc.GetCell(DefaultTC.colName.TYPE);

            uint order = 0;

            while (true)
            {
                row++;
                string c0 = itc.GetSubCase(row, DefaultTC.subColName.ID0);
                string c1 = itc.GetSubCase(row, DefaultTC.subColName.ID);

                if (c0.Length != 0 || c1.Length == 0)
                {
                    row--;
                    return(row);
                }

                string   c2 = itc.GetSubCase(row, DefaultTC.subColName.SAMPLES);
                testcase tc = new testcase();
                tc.name           = c1;
                tc.externalid     = externalid++;
                tc.internalid     = externalid + "";
                tc.node_order     = order++;
                tc.version        = 1;
                tc.summary        = c2;
                tc.preconditions  = preset;
                tc.execution_type = (uint)(can_auto ? 2 : 1);
                if (importance.Length > 5)
                {
                    tc.importance = Convert.ToUInt32(importance.Substring(5, 1));
                }
                else
                {
                    tc.importance = 1;
                }
                custom_field test_type = new custom_field();
                test_type.name  = "test_type";
                test_type.value = testtype;
                tc.custom_fields.Add(test_type);

                //todo 需求没有处理
                //string reqs= itc.GetSubCase(row,DefaultTC.subColName.REQ);
                //requirement rq=new requirement();

                //tc.requirements.Add

                for (int i = 0; i < steps.Count; i++)
                {
                    step s = new step();
                    s.actions         = steps[i];
                    s.expectedresults = exp[i];
                    s.step_number     = (uint)(i + 1);
                    s.execution_type  = tc.execution_type;
                    tc.steps.Add(s);
                }

                ts.Items.Add(tc);
            }
        }