public CmdGenerateTData(ExcelDataAccess dtAccess)
 {
     _dtAccess = dtAccess;
     listTCase = _dtAccess.getTestcases();
     List<TestData> listTData = _dtAccess.getTestdatas();
     beginID = listTData.Count;
 }
        /**
         * Excute function with input = values, then return output result.
         * Use this method to excute not void function.
         * */
        public static bool ExcuteFunction(string keyword, string values,ref string error_mes, ref object output)
        {
            try
            {
                List<StringReplace> listReplace = util.getReplaceString(ref values);

                ReflectMethod meth = Methods.Single(w => w._Keyword.Equals(keyword));
                List<string> listValue = util.getListValueFromString(values);
                int n = listValue.Count;
                if (n == 1 && listValue[0].Equals("")) {
                    n = 0;
                }

                List<string> ArgTypes = meth.getArgumentsType();
                if (n != ArgTypes.Count) {
                    error_mes = ErrorMessage.INVALID_METHOD_ARGUMENT;
                    return false;
                }
                for (int i = 0; i < n; i++)
                {
                    foreach (StringReplace strReplace in listReplace)
                    {
                        if (listValue[i].Equals(strReplace.Replace))
                        {
                            listValue[i] = strReplace.Value;
                            break;
                        }
                    }
                }
                object[] mParam = new object[n];
                for (int i = 0; i < n; i++)
                {
                    object tam = null;
                    if (!getOdject(ArgTypes[i], listValue[i], ref tam))
                    {
                        error_mes = ErrorMessage.CONVERSION_TYPE;
                        return false;
                    }
                    mParam[i] = tam;
                }
                string excuteMes = "";
                Dictionary<string, string> listTConfig = new Dictionary<string, string>();
                string excelPath = ConfigurationSettings.AppSettings["ExcelFile"];
                ExcelDataAccess exceldataAccess = new ExcelDataAccess(excelPath);
                listTConfig = exceldataAccess.getTestConfig();
                bool flag = meth.Excute(mParam, ref output, ref excuteMes, listTConfig);
                if (flag == false)
                {
                    error_mes = ErrorMessage.USERCODE + "\n" + excuteMes;
                    return false;
                }
                return true;
            }
            catch (Exception e)
            {
                error_mes = ErrorMessage.USERCODE;
                return false;
            }
        }
 public BuildRelease(ExcelDataAccess dtAccess, string DesPath,string scriptName)
 {
     _dtAccess = dtAccess;
     listTCase = _dtAccess.getTestcases();
     listTStep = _dtAccess.getTeststeps();
     Commands = _dtAccess.getTestcommands();
     Datas = _dtAccess.getTestdatas();
     string DesRelease = DesPath;
     //build = new Build(DesRelease, scriptName);
 }
 public BuildRelease(ExcelDataAccess dtAccess,string DesPath)
 {
     _dtAccess = dtAccess;
     listTCase = _dtAccess.getTestcases();
     listTStep = _dtAccess.getTeststeps();
     Commands = _dtAccess.getTestcommands();
     _ListTestConfig = _dtAccess.getTestConfigs();
     Datas = _dtAccess.getTestdatas();
     _DesPath = DesPath;
     //build = new Build(DesRelease);
 }
Beispiel #5
0
        static void Main(string[] args)
        {
            XmlDataAccess XmlHelper1 = new XmlDataAccess("performanceConfig.xml");
            XmlDataAccess XmlHelper2 = new XmlDataAccess("performanceInput.xml");
            XmlDataAccess XmlHelper3 = new XmlDataAccess("performanceReport.xml");
            List<TestCommand> listTCommand = XmlHelper1.getTestCommands();
            ComponentFunction.Initialize(listTCommand);
            List<TestSuite> listTSuite = XmlHelper1.getTestSuites();
            List<TestData> listTData = new List<TestData>();
            Dictionary<string, string> listTConfig = new Dictionary<string, string>();

            string excelPath = ConfigurationSettings.AppSettings["ExcelFile"];

            ExcelDataAccess exceldataAccess = new ExcelDataAccess(excelPath);
            listTConfig = exceldataAccess.getTestConfig();

            listTConfig = XmlHelper1.getTestConfig();

            foreach (TestSuite tsuite in listTSuite) {
                string Log = "";
                if (tsuite.Construct(ref Log)) {
                    List<string> listvalues = XmlHelper2.getValues(tsuite.getName());
                    foreach (string values in listvalues) {
                        Log = "";
                        TestData temp = new TestData();

                        string description = string.Empty;
                        if (tsuite.Debug(values, ref Log, ref description, listTConfig))
                        {
                            temp.TestCase = tsuite.getName();
                            temp.Values = values;
                            temp.Result = Glossary.PASS;
                            temp.Comment = Log;
                        }else{
                            temp.TestCase = tsuite.getName();
                            temp.Values = values;
                            temp.Result = Glossary.FAILURE;
                            temp.Comment = Log;
                        }
                        listTData.Add(temp);
                    }
                }
            }
            XmlHelper3.BuildReport(listTData);
            Console.ReadLine();
        }
Beispiel #6
0
        //Features
        static void Main(string[] args)
        {
            //List<TestCommand> list = ComponentFunction.GetAllMethodsDLLs(@"d:\AutomationTest\APPLICATIONMAP\AppLibrary.dll");

            //string ExcelPath = "test.xls";

            string ExcelPath = ConfigurationSettings.AppSettings["ExcelFile"];

            dtAccess = new ExcelDataAccess(ExcelPath);

            //listTCase = dtAccess.getTestcases();
            //listTCommand = dtAccess.getTestcommands();
            //listTDataset = dtAccess.getTestdatasets();
            //listTStep = dtAccess.getTeststeps();
            //listTData = dtAccess.getTestdatas();
            ////ComponentFunction.Initialize(listTCommand);
            //DebugTestCases();
            //GenerateDatas();
            //GenerateCommands();
            //CmdGenerateDatas();
            //CmdExcuteKeyword();
            while (true) {

                bool flag = true;
                Console.WriteLine("AUTOMATION SOFTWARE V1.");
                Console.WriteLine("1: DebugTestCases.");
                Console.WriteLine("2: Generate TestData from excel.");
                Console.WriteLine("3: Cmd Excute Keyword.");
                Console.WriteLine("4: Cmd Generate TestData.");
                Console.WriteLine("5: Generate Commands.");
                Console.WriteLine("6: Build Release.");
                Console.WriteLine("7: DebugTestCases in multithread mode.");
                Console.WriteLine("8: Refresh.");
                Console.WriteLine("/e: Exit");
                Console.Write("Your choice:");

                //string arg = args[0];
                string input = string.Empty;

                if (args.Length > 0)
                {
                    input = args[0];
                }
                else
                {
                     input = Console.ReadLine();
                }
                Console.Write(input);
                switch (input) {
                    case "1":

                        DebugTestCases();
                        flag = false;
                        break;
                    case "2":
                        GenerateDatas();
                        flag = false;
                        break;
                    case "3":
                        CmdExcuteKeyword();
                        flag = false;
                        break;
                    case "4":
                        CmdGenerateDatas();
                        flag = false;
                        break;
                    case "5":
                        GenerateCommands();
                        flag = false;
                        break;
                    case "6":
                        BuildRelease();
                        flag = false;
                        break;
                    case "7":
                        DebugTestCasesMultithread();
                        flag = false;
                        break;
                    case "8":
                        Refresh();
                        flag = false;
                        break;
                    case "/e":
                        flag = false;
                        break;
                }
                if (!flag)
                    break;
            }

            Console.ReadLine();
        }
Beispiel #7
0
        public List<TestData> Run()
        {
            foreach (TestData tdata in _listTDatas)
            {
                if (tdata.Result.Equals("") || tdata.Result.Equals(Glossary.NOTRUN))
                {

                    string temp = "";
                    string description = string.Empty;
                    Dictionary<string, string> listTConfig = new Dictionary<string, string>();
                    string excelPath = ConfigurationSettings.AppSettings["ExcelFile"];
                    ExcelDataAccess exceldataAccess = new ExcelDataAccess(excelPath);
                    listTConfig = exceldataAccess.getTestConfig();
                    if (Debug(tdata.Values, ref temp, ref description, listTConfig))
                    {
                        tdata.Result = Glossary.PASS;
                    }
                    else
                    {
                        tdata.Result = Glossary.FAILURE;
                        tdata.Comment = temp;
                    }
                }
            }
            return _listTDatas;
        }
 public DebugMultithread(ExcelDataAccess dtAccess)
 {
     List<TestCommand> Commands = dtAccess.getTestcommands();
     ComponentFunction.Initialize(Commands);
     _dtAccess = dtAccess;
 }