Example #1
0
 public TestSuite(List<TestStep> listTStep, TestCase TCase)
 {
     if (ComponentFunction.NotInitialized()) {
         Console.WriteLine("You have to initialize ComponentFunction first.");
         throw new Exception("Not initialize ComponentFunction yet!");
     }
     _TCase = TCase;
     _Name = TCase.Name;
     _Behavior = TCase.Behavior;
     //Default: Behavior = Sequence
     if (_Behavior.Equals(""))
         _Behavior = Glossary.SEQUENCE;
     _State = TCase.State;
     if (_State.Equals(""))
         _State = Glossary.NOTRUN;
     foreach (var item in listTStep)
     {
         if (item.TestCase.Equals(_Name))
             _listTStep.Add(item);
     }
 }
 private bool GenerateTestDatas(List<string> listvalues, TestCase tcase)
 {
     if (_dtAccess != null)
     {
         if (beginID == 0)
             beginID++;
         List<string> listParams = util.getListValueFromString(tcase.Parameters);
         int nArgument = listParams.Count;
         if (nArgument == 1 && listParams[0].Equals(""))
         {
             Out.WriteLine("TCase name=" + tcase.Name + " have no arguments");
             return false;
         }
         else
         {
             List<TestData> newDatas = new List<TestData>();
             foreach (string item in listvalues)
             {
                 int n = util.getListValueFromString(item).Count;
                 if (n != nArgument)
                 {
                     Error.WriteLine("The number of arguments input isnot valid.");
                     return false;
                 }
                 else
                 {
                     TestData temp = new TestData();
                     temp.ID = beginID.ToString();
                     temp.Comment = "Data generate by pict.";
                     temp.TestCase = tcase.Name;
                     temp.Values = item;
                     temp.Result = "";
                     beginID++;
                     newDatas.Add(temp);
                 }
             }
             if (newDatas.Count > 0)
             {
                 _dtAccess.GenerateTestdatas(newDatas);
                 Out.WriteLine("Generate TData for TCase=" + tcase.Name + " successful.");
                 Out.WriteLine("There are " + newDatas.Count + " TestDatas generated by pict.");
             }
             else
             {
                 Error.WriteLine("Generate TData for TCase=" + tcase.Name + " unsuccessful.");
                 Error.WriteLine("No valid TData to generate.");
                 return false;
             }
         }
     }
     return true;
 }
 public List<TestSuite> getTestSuites()
 {
     List<TestSuite> rs = new List<TestSuite>();
     foreach (var item in _xElement.Elements("TestCase"))
     {
         TestCase tcase = new TestCase();
         List<TestStep> listStep = new List<TestStep>();
         tcase.Name = item.Attribute("Name").Value;
         tcase.Parameters = item.Attribute("Parameters").Value;
         tcase.Behavior = item.Attribute("Behavior").Value;
         tcase.State = item.Attribute("State").Value;
         tcase.ID = item.Attribute("ID").Value;
         foreach (var step in item.Elements("TestStep"))
         {
             TestStep temp_step = new TestStep();
             temp_step.TestCase = tcase.Name;
             temp_step.ID = step.Attribute("ID").Value;
             temp_step.Keyword = step.Attribute("Keyword").Value;
             temp_step.Parameters = step.Attribute("Parameters").Value;
             temp_step.Output = step.Attribute("Output").Value;
             temp_step.Comment = "";
             listStep.Add(temp_step);
         }
         rs.Add(new TestSuite(listStep, tcase));
     }
     return rs;
 }