Esempio n. 1
0
 /// <summary>
 /// constructor
 /// </summary>
 /// <param name="runNotifier"></param>
 /// <param name="useUftLicense"></param>
 /// <param name="timeLeftUntilTimeout"></param>
 public GuiTestRunner(IAssetRunner runNotifier, bool useUftLicense, TimeSpan timeLeftUntilTimeout, McConnectionInfo mcConnectionInfo, string mobileInfo)
 {
     _timeLeftUntilTimeout = timeLeftUntilTimeout;
     _stopwatch            = Stopwatch.StartNew();
     _runNotifier          = runNotifier;
     _useUFTLicense        = useUftLicense;
     _mcConnection         = mcConnectionInfo;
     _mobileInfo           = mobileInfo;
 }
Esempio n. 2
0
 /// <summary>
 /// overloaded constructor for adding support for run mode selection
 /// </summary>
 /// <param name="sources"></param>
 /// <param name="timeout"></param>
 /// <param name="uftRunMode"></param>
 /// <param name="backgroundWorker"></param>
 /// <param name="useUFTLicense"></param>
 public FileSystemTestsRunner(List <string> sources,
                              TimeSpan timeout,
                              string uftRunMode,
                              int ControllerPollingInterval,
                              TimeSpan perScenarioTimeOutMinutes,
                              List <string> ignoreErrorStrings,
                              Dictionary <string, string> jenkinsEnvVariables,
                              McConnectionInfo mcConnection,
                              string mobileInfo,
                              bool useUFTLicense = false)
     : this(sources, timeout, ControllerPollingInterval, perScenarioTimeOutMinutes, ignoreErrorStrings, jenkinsEnvVariables, mcConnection, mobileInfo, useUFTLicense)
 {
     _uftRunMode = uftRunMode;
 }
Esempio n. 3
0
        /// <summary>
        /// overloaded constructor for adding support for run mode selection
        /// </summary>
        /// <param name="sources"></param>
        /// <param name="timeout"></param>
        /// <param name="uftRunMode"></param>
        /// <param name="backgroundWorker"></param>
        /// <param name="useUFTLicense"></param>
        public FileSystemTestsRunner(List <TestData> sources,
                                     TimeSpan timeout,
                                     string uftRunMode,
                                     int ControllerPollingInterval,
                                     TimeSpan perScenarioTimeOutMinutes,
                                     List <string> ignoreErrorStrings,
                                     Dictionary <string, string> jenkinsEnvVariables,
                                     McConnectionInfo mcConnection,
                                     string mobileInfo,
                                     Dictionary <string, List <string> > parallelRunnerEnvironments,
                                     bool displayController,
                                     string analysisTemplate,
                                     bool useUFTLicense = false)

            : this(sources, timeout, ControllerPollingInterval, perScenarioTimeOutMinutes, ignoreErrorStrings, jenkinsEnvVariables, mcConnection, mobileInfo, parallelRunnerEnvironments, displayController, analysisTemplate, useUFTLicense)
        {
            _uftRunMode = uftRunMode;
        }
        /// <summary>
        /// creates the correct runner according to the given type
        /// </summary>
        /// <param name="runType"></param>
        /// <param name="ciParams"></param>
        IAssetRunner CreateRunner(TestStorageType runType, JavaProperties ciParams)
        {
            IAssetRunner runner = null;
            switch (runType)
            {
                case TestStorageType.Alm:
                    //check that all required parameters exist
                    foreach (string param1 in requiredParamsForQcRun)
                    {
                        if (!_ciParams.ContainsKey(param1))
                        {
                            ConsoleWriter.WriteLine(string.Format(Resources.LauncherParamRequired, param1));
                            return null;
                        }
                    }

                    //parse params that need parsing
                    double dblQcTimeout = int.MaxValue;
                    if (!double.TryParse(_ciParams["almTimeout"], out dblQcTimeout))
                    {
                        ConsoleWriter.WriteLine(Resources.LauncherTimeoutNotNumeric);
                        dblQcTimeout = int.MaxValue;
                    }

                    ConsoleWriter.WriteLine(string.Format(Resources.LuancherDisplayTimout, dblQcTimeout));

                    QcRunMode enmQcRunMode = QcRunMode.RUN_LOCAL;
                    if (!Enum.TryParse<QcRunMode>(_ciParams["almRunMode"], true, out enmQcRunMode))
                    {
                        ConsoleWriter.WriteLine(Resources.LauncherIncorrectRunmode);
                        enmQcRunMode = QcRunMode.RUN_LOCAL;
                    }
                    ConsoleWriter.WriteLine(string.Format(Resources.LauncherDisplayRunmode, enmQcRunMode.ToString()));

                    //go over testsets in the parameters, and collect them
                    List<string> sets = GetParamsWithPrefix("TestSet");

                    if (sets.Count == 0)
                    {
                        ConsoleWriter.WriteLine(Resources.LauncherNoTests);
                        return null;
                    }

                    //create an Alm runner
                    runner = new AlmTestSetsRunner(_ciParams["almServerUrl"],
                                     _ciParams["almUserName"],
                                     Decrypt(_ciParams["almPassword"], secretkey),
                                     _ciParams["almDomain"],
                                     _ciParams["almProject"],
                                     dblQcTimeout,
                                     enmQcRunMode,
                                     _ciParams["almRunHost"],
                                     sets);
                    break;
                case TestStorageType.FileSystem:

                    //get the tests
                    IEnumerable<string> tests = GetParamsWithPrefix("Test");

                    IEnumerable<string> jenkinsEnvVariablesWithCommas = GetParamsWithPrefix("JenkinsEnv");
                    Dictionary<string, string> jenkinsEnvVariables = new Dictionary<string,string>();
                    foreach (string var in jenkinsEnvVariablesWithCommas)
                    {
                        string[] nameVal = var.Split(",;".ToCharArray());
                        jenkinsEnvVariables.Add(nameVal[0], nameVal[1]);
                    }
                    //parse the timeout into a TimeSpan
                    TimeSpan timeout = TimeSpan.MaxValue;
                    if (_ciParams.ContainsKey("fsTimeout"))
                    {
                        string strTimoutInSeconds = _ciParams["fsTimeout"];
                        if (strTimoutInSeconds.Trim() != "-1")
                        {
                            int intTimoutInSeconds = 0;
                            int.TryParse(strTimoutInSeconds, out intTimoutInSeconds);
                            timeout = TimeSpan.FromSeconds(intTimoutInSeconds);
                        }
                    }
                    ConsoleWriter.WriteLine("Launcher timeout is " + timeout.ToString(@"dd\:\:hh\:mm\:ss"));

                    //LR specific values:
                    //default values are set by JAVA code, in com.hp.application.automation.tools.model.RunFromFileSystemModel.java

                    int pollingInterval = 30;
                    if (_ciParams.ContainsKey("controllerPollingInterval"))
                        pollingInterval = int.Parse(_ciParams["controllerPollingInterval"]);

                    TimeSpan perScenarioTimeOutMinutes = TimeSpan.MaxValue;
                    if (_ciParams.ContainsKey("PerScenarioTimeOut"))
                    {
                        string strTimoutInMinutes = _ciParams["PerScenarioTimeOut"];
                        ConsoleWriter.WriteLine("reading PerScenarioTimeout: "+strTimoutInMinutes);
                        if (strTimoutInMinutes.Trim() != "-1")
                        {
                            int intTimoutInMinutes = 0;
                            if (int.TryParse(strTimoutInMinutes, out intTimoutInMinutes))
                                perScenarioTimeOutMinutes = TimeSpan.FromMinutes(intTimoutInMinutes);
                            ConsoleWriter.WriteLine("PerScenarioTimeout: "+perScenarioTimeOutMinutes+" minutes");
                        }
                    }
                    ConsoleWriter.WriteLine("PerScenarioTimeout: " + perScenarioTimeOutMinutes.ToString(@"dd\:\:hh\:mm\:ss") + " minutes");

                    char[] delim = { '\n' };
                    List<string> ignoreErrorStrings = new List<string>();
                    if (_ciParams.ContainsKey("ignoreErrorStrings"))
                    {
                        ignoreErrorStrings.AddRange(_ciParams["ignoreErrorStrings"].Split(delim, StringSplitOptions.RemoveEmptyEntries));
                    }

                    if (tests == null || tests.Count() == 0)
                    {
                        WriteToConsole(Resources.LauncherNoTestsFound);
                    }

                    List<string> validTests = Helper.ValidateFiles(tests);

                    if (tests != null && tests.Count() > 0 && validTests.Count == 0)
                    {
                        ConsoleWriter.WriteLine(Resources.LauncherNoValidTests);
                        return null;
                    }

                    //--MC connection info
                    McConnectionInfo mcConnectionInfo = new McConnectionInfo();
                    if (_ciParams.ContainsKey("MobileHostAddress"))
                    {
                        string mcServerUrl = _ciParams["MobileHostAddress"];

                        if (!string.IsNullOrEmpty(mcServerUrl) )
                        {
                            //url is something like http://xxx.xxx.xxx.xxx:8080
                            string[] strArray = mcServerUrl.Split(new Char[] { ':' });
                            if (strArray.Length == 3)
                            {
                                mcConnectionInfo.MobileHostAddress = strArray[1].Replace("/", "");
                                mcConnectionInfo.MobileHostPort = strArray[2];
                            }

                            //mc username
                            if (_ciParams.ContainsKey("MobileUserName"))
                            {
                                string mcUsername = _ciParams["MobileUserName"];
                                if (!string.IsNullOrEmpty(mcUsername))
                                {
                                    mcConnectionInfo.MobileUserName = mcUsername;
                                }
                            }

                            //mc password
                            if (_ciParams.ContainsKey("MobilePassword"))
                            {
                                string mcPassword = _ciParams["MobilePassword"];
                                if (!string.IsNullOrEmpty(mcPassword))
                                {
                                    mcConnectionInfo.MobilePassword = Decrypt(mcPassword, secretkey);
                                }
                            }

                            //ssl
                            if (_ciParams.ContainsKey("MobileUseSSL"))
                            {
                                string mcUseSSL = _ciParams["MobileUseSSL"];
                                if (!string.IsNullOrEmpty(mcUseSSL))
                                {
                                    mcConnectionInfo.MobileUseSSL = int.Parse(mcUseSSL);
                                }
                            }

                            //Proxy enabled flag
                            if (_ciParams.ContainsKey("MobileUseProxy"))
                            {
                                string useProxy = _ciParams["MobileUseProxy"];
                                if (!string.IsNullOrEmpty(useProxy))
                                {
                                    mcConnectionInfo.MobileUseProxy = int.Parse(useProxy);
                                }
                            }

                            //Proxy type
                            if (_ciParams.ContainsKey("MobileProxyType"))
                            {
                                string proxyType = _ciParams["MobileProxyType"];
                                if (!string.IsNullOrEmpty(proxyType))
                                {
                                    mcConnectionInfo.MobileProxyType = int.Parse(proxyType);
                                }
                            }

                            //proxy address
                            if (_ciParams.ContainsKey("MobileProxySetting_Address"))
                            {
                                string proxyAddress = _ciParams["MobileProxySetting_Address"];
                                if (!string.IsNullOrEmpty(proxyAddress))
                                {
                                    // data is something like "16.105.9.23:8080"
                                    string[] strArray4ProxyAddr = proxyAddress.Split(new Char[] { ':' });
                                    if (strArray.Length == 2)
                                    {
                                        mcConnectionInfo.MobileProxySetting_Address = strArray4ProxyAddr[0];
                                        mcConnectionInfo.MobileProxySetting_Port = int.Parse(strArray4ProxyAddr[1]);
                                    }
                                }
                            }

                            //Proxy authentication
                            if (_ciParams.ContainsKey("MobileProxySetting_Authentication"))
                            {
                                string proxyAuthentication = _ciParams["MobileProxySetting_Authentication"];
                                if (!string.IsNullOrEmpty(proxyAuthentication))
                                {
                                    mcConnectionInfo.MobileProxySetting_Authentication = int.Parse(proxyAuthentication);
                                }
                            }

                            //Proxy username
                            if (_ciParams.ContainsKey("MobileProxySetting_UserName"))
                            {
                                string proxyUsername = _ciParams["MobileProxySetting_UserName"];
                                if (!string.IsNullOrEmpty(proxyUsername))
                                {
                                    mcConnectionInfo.MobileProxySetting_UserName = proxyUsername;
                                }
                            }

                            //Proxy password
                            if (_ciParams.ContainsKey("MobileProxySetting_Password"))
                            {
                                string proxyPassword = _ciParams["MobileProxySetting_Password"];
                                if (!string.IsNullOrEmpty(proxyPassword))
                                {
                                    mcConnectionInfo.MobileProxySetting_Password = Decrypt(proxyPassword, secretkey);
                                }
                            }

                        }
                    }

                    // other mobile info
                    string mobileinfo = "";
                    if (_ciParams.ContainsKey("mobileinfo"))
                    {
                        mobileinfo = _ciParams["mobileinfo"];
                    }

                    runner = new FileSystemTestsRunner(validTests, timeout, pollingInterval, perScenarioTimeOutMinutes, ignoreErrorStrings, jenkinsEnvVariables, mcConnectionInfo, mobileinfo);

                    break;

                default:
                    runner = null;
                    break;
            }
            return runner;
        }
Esempio n. 5
0
        /// <summary>
        /// creates instance of the runner given a source.
        /// </summary>
        /// <param name="sources"></param>
        /// <param name="timeout"></param>
        /// <param name="backgroundWorker"></param>
        /// <param name="useUFTLicense"></param>
        public FileSystemTestsRunner(List <string> sources,
                                     TimeSpan timeout,
                                     int ControllerPollingInterval,
                                     TimeSpan perScenarioTimeOutMinutes,
                                     List <string> ignoreErrorStrings,
                                     Dictionary <string, string> jenkinsEnvVariables,
                                     McConnectionInfo mcConnection,
                                     string mobileInfo,
                                     bool useUFTLicense = false
                                     )
        {
            _jenkinsEnvVariables = jenkinsEnvVariables;
            //search if we have any testing tools installed
            if (!Helper.IsTestingToolsInstalled(TestStorageType.FileSystem))
            {
                ConsoleWriter.WriteErrLine(string.Format(Resources.FileSystemTestsRunner_No_HP_testing_tool_is_installed_on, System.Environment.MachineName));
                Environment.Exit((int)Launcher.ExitCodeEnum.Failed);
            }

            _timeout = timeout;
            ConsoleWriter.WriteLine("FileSystemTestRunner timeout is " + _timeout);
            _stopwatch = Stopwatch.StartNew();

            _pollingInterval           = ControllerPollingInterval;
            _perScenarioTimeOutMinutes = perScenarioTimeOutMinutes;
            _ignoreErrorStrings        = ignoreErrorStrings;


            _useUFTLicense = useUFTLicense;
            _tests         = new List <TestInfo>();

            _mcConnection             = mcConnection;
            _mobileInfoForAllGuiTests = mobileInfo;

            ConsoleWriter.WriteLine("Mc connection info is - " + _mcConnection.ToString());

            //go over all sources, and create a list of all tests
            foreach (string source in sources)
            {
                List <TestInfo> testGroup = new List <TestInfo>();
                try
                {
                    //--handle directories which contain test subdirectories (recursively)
                    if (Helper.IsDirectory(source))
                    {
                        var testsLocations = Helper.GetTestsLocations(source);
                        foreach (var loc in testsLocations)
                        {
                            var test = new TestInfo(loc, loc, source);
                            testGroup.Add(test);
                        }
                    }
                    //--handle mtb files (which contain links to tests)
                    else
                    //file might be LoadRunner scenario or
                    //mtb file (which contain links to tests)
                    //other files are dropped
                    {
                        testGroup = new List <TestInfo>();
                        FileInfo fi = new FileInfo(source);
                        if (fi.Extension == Helper.LoadRunnerFileExtention)
                        {
                            testGroup.Add(new TestInfo(source, source, source));
                        }
                        else if (fi.Extension == ".mtb")
                        //if (source.TrimEnd().EndsWith(".mtb", StringComparison.CurrentCultureIgnoreCase))
                        {
                            MtbManager manager = new MtbManager();
                            var        paths   = manager.Parse(source);
                            foreach (var p in paths)
                            {
                                testGroup.Add(new TestInfo(p, p, source));
                            }
                        }
                        else if (fi.Extension == ".mtbx")
                        //if (source.TrimEnd().EndsWith(".mtb", StringComparison.CurrentCultureIgnoreCase))
                        {
                            testGroup = MtbxManager.Parse(source, _jenkinsEnvVariables, source);
                        }
                    }
                }
                catch (Exception)
                {
                    testGroup = new List <TestInfo>();
                }

                //--handle single test dir, add it with no group
                if (testGroup.Count == 1)
                {
                    testGroup[0].TestGroup = "<None>";
                }

                _tests.AddRange(testGroup);
            }

            if (_tests == null || _tests.Count == 0)
            {
                ConsoleWriter.WriteLine(Resources.FsRunnerNoValidTests);
                Environment.Exit((int)Launcher.ExitCodeEnum.Failed);
            }

            ConsoleWriter.WriteLine(string.Format(Resources.FsRunnerTestsFound, _tests.Count));
            _tests.ForEach(t => ConsoleWriter.WriteLine("" + t.TestName));
            ConsoleWriter.WriteLine(Resources.GeneralDoubleSeperator);
        }
        /// <summary>
        /// creates instance of the runner given a source.
        /// </summary>
        /// <param name="sources"></param>
        /// <param name="timeout"></param>
        /// <param name="scriptRtsSet"></param>
        /// <param name="reportPath">The report base directory for all running tests.</param>
        /// <param name="controllerPollingInterval"></param>
        /// <param name="perScenarioTimeOutMinutes"></param>
        /// <param name="ignoreErrorStrings"></param>
        /// <param name="jenkinsEnvVariables"></param>
        /// <param name="mcConnection"></param>
        /// <param name="mobileInfo"></param>
        /// <param name="parallelRunnerEnvironments"></param>
        /// <param name="displayController"></param>
        /// <param name="analysisTemplate"></param>
        /// <param name="summaryDataLogger"></param>
        /// <param name="useUftLicense"></param>
        public FileSystemTestsRunner(List <TestData> sources,
                                     TimeSpan timeout,
                                     int controllerPollingInterval,
                                     TimeSpan perScenarioTimeOutMinutes,
                                     List <string> ignoreErrorStrings,
                                     Dictionary <string, string> jenkinsEnvVariables,
                                     McConnectionInfo mcConnection,
                                     string mobileInfo,
                                     Dictionary <string, List <string> > parallelRunnerEnvironments,
                                     bool displayController,
                                     string analysisTemplate,
                                     SummaryDataLogger summaryDataLogger,
                                     List <ScriptRTSModel> scriptRtsSet,
                                     string reportPath,
                                     bool useUftLicense = false)
        {
            _jenkinsEnvVariables = jenkinsEnvVariables;
            //search if we have any testing tools installed
            if (!Helper.IsTestingToolsInstalled(TestStorageType.FileSystem))
            {
                ConsoleWriter.WriteErrLine(string.Format(Resources.FileSystemTestsRunner_No_HP_testing_tool_is_installed_on, System.Environment.MachineName));
                Environment.Exit((int)Launcher.ExitCodeEnum.Failed);
            }

            _timeout = timeout;
            ConsoleWriter.WriteLine("FileSystemTestRunner timeout is " + _timeout);
            _stopwatch = Stopwatch.StartNew();

            _pollingInterval           = controllerPollingInterval;
            _perScenarioTimeOutMinutes = perScenarioTimeOutMinutes;
            _ignoreErrorStrings        = ignoreErrorStrings;

            _useUFTLicense     = useUftLicense;
            _displayController = displayController;
            _analysisTemplate  = analysisTemplate;
            _summaryDataLogger = summaryDataLogger;
            _scriptRTSSet      = scriptRtsSet;
            _tests             = new List <TestInfo>();

            _mcConnection             = mcConnection;
            _mobileInfoForAllGuiTests = mobileInfo;

            _parallelRunnerEnvironments = parallelRunnerEnvironments;

            if (!string.IsNullOrWhiteSpace(_mcConnection.MobileHostAddress))
            {
                ConsoleWriter.WriteLine("UFT Mobile connection info is - " + _mcConnection.ToString());
            }

            if (reportPath != null)
            {
                ConsoleWriter.WriteLine("Results base directory (for all tests) is: " + reportPath);
            }

            //go over all sources, and create a list of all tests
            foreach (TestData source in sources)
            {
                List <TestInfo> testGroup = new List <TestInfo>();
                try
                {
                    //--handle directories which contain test subdirectories (recursively)
                    if (Helper.IsDirectory(source.Tests))
                    {
                        var testsLocations = Helper.GetTestsLocations(source.Tests);
                        foreach (var loc in testsLocations)
                        {
                            var test = new TestInfo(loc, loc, source.Tests, source.Id)
                            {
                                ReportPath = source.ReportPath
                            };
                            testGroup.Add(test);
                        }
                    }
                    //--handle mtb files (which contain links to tests)
                    else
                    //file might be LoadRunner scenario or
                    //mtb file (which contain links to tests)
                    //other files are dropped
                    {
                        testGroup = new List <TestInfo>();
                        FileInfo fi = new FileInfo(source.Tests);
                        if (fi.Extension == Helper.LoadRunnerFileExtention)
                        {
                            testGroup.Add(new TestInfo(source.Tests, source.Tests, source.Tests, source.Id)
                            {
                                ReportPath = source.ReportPath
                            });
                        }
                        else if (fi.Extension == ".mtb")
                        //if (source.TrimEnd().EndsWith(".mtb", StringComparison.CurrentCultureIgnoreCase))
                        {
                            MtbManager manager = new MtbManager();
                            var        paths   = manager.Parse(source.Tests);
                            foreach (var p in paths)
                            {
                                testGroup.Add(new TestInfo(p, p, source.Tests, source.Id));
                            }
                        }
                        else if (fi.Extension == ".mtbx")
                        {
                            testGroup = MtbxManager.Parse(source.Tests, _jenkinsEnvVariables, source.Tests);

                            // set the test Id for each test from the group
                            // this is important for parallel runner
                            foreach (var testInfo in testGroup)
                            {
                                testInfo.TestId = source.Id;
                            }
                        }
                    }
                }
                catch (Exception)
                {
                    testGroup = new List <TestInfo>();
                }

                //--handle single test dir, add it with no group
                if (testGroup.Count == 1)
                {
                    testGroup[0].TestGroup = "Test group";
                }

                _tests.AddRange(testGroup);
            }

            if (_tests == null || _tests.Count == 0)
            {
                ConsoleWriter.WriteLine(Resources.FsRunnerNoValidTests);
                Environment.Exit((int)Launcher.ExitCodeEnum.Failed);
            }

            // if a custom path was provided,set the custom report path for all the valid tests(this will overwrite the default location)
            if (reportPath != null)
            {
                foreach (TestInfo t in _tests)
                {
                    if (string.IsNullOrWhiteSpace(t.ReportBaseDirectory))
                    {
                        t.ReportBaseDirectory = reportPath;
                    }
                }
            }

            ConsoleWriter.WriteLine(string.Format(Resources.FsRunnerTestsFound, _tests.Count));

            foreach (var test in _tests)
            {
                ConsoleWriter.WriteLine("" + test.TestName);
                if (parallelRunnerEnvironments.ContainsKey(test.TestId))
                {
                    parallelRunnerEnvironments[test.TestId].ForEach(
                        env => ConsoleWriter.WriteLine("    " + env));
                }
            }

            ConsoleWriter.WriteLine(Resources.GeneralDoubleSeperator);
        }
Esempio n. 7
0
        /// <summary>
        /// creates the correct runner according to the given type
        /// </summary>
        /// <param name="runType"></param>
        /// <param name="ciParams"></param>
        IAssetRunner CreateRunner(TestStorageType runType, JavaProperties ciParams)
        {
            IAssetRunner runner = null;

            switch (runType)
            {
            case TestStorageType.Alm:
                //check that all required parameters exist
                foreach (string param1 in requiredParamsForQcRun)
                {
                    if (!_ciParams.ContainsKey(param1))
                    {
                        ConsoleWriter.WriteLine(string.Format(Resources.LauncherParamRequired, param1));
                        return(null);
                    }
                }

                //parse params that need parsing
                double dblQcTimeout = int.MaxValue;
                if (!double.TryParse(_ciParams["almTimeout"], out dblQcTimeout))
                {
                    ConsoleWriter.WriteLine(Resources.LauncherTimeoutNotNumeric);
                    dblQcTimeout = int.MaxValue;
                }

                ConsoleWriter.WriteLine(string.Format(Resources.LuancherDisplayTimout, dblQcTimeout));

                QcRunMode enmQcRunMode = QcRunMode.RUN_LOCAL;
                if (!Enum.TryParse <QcRunMode>(_ciParams["almRunMode"], true, out enmQcRunMode))
                {
                    ConsoleWriter.WriteLine(Resources.LauncherIncorrectRunmode);
                    enmQcRunMode = QcRunMode.RUN_LOCAL;
                }
                ConsoleWriter.WriteLine(string.Format(Resources.LauncherDisplayRunmode, enmQcRunMode.ToString()));

                //go over testsets in the parameters, and collect them
                List <string> sets = GetParamsWithPrefix("TestSet");

                if (sets.Count == 0)
                {
                    ConsoleWriter.WriteLine(Resources.LauncherNoTests);
                    return(null);
                }

                //create an Alm runner
                runner = new AlmTestSetsRunner(_ciParams["almServerUrl"],
                                               _ciParams["almUserName"],
                                               Decrypt(_ciParams["almPassword"], secretkey),
                                               _ciParams["almDomain"],
                                               _ciParams["almProject"],
                                               dblQcTimeout,
                                               enmQcRunMode,
                                               _ciParams["almRunHost"],
                                               sets);
                break;

            case TestStorageType.FileSystem:
                //Get displayController var
                bool displayController = false;
                if (_ciParams.ContainsKey("displayController"))
                {
                    if (_ciParams["displayController"] == "1")
                    {
                        displayController = true;
                    }
                }
                string analysisTemplate = (_ciParams.ContainsKey("analysisTemplate") ? _ciParams["analysisTemplate"] : "");

                Dictionary <string, string> testsKeyValue = GetKeyValuesWithPrefix("Test");
                List <TestData>             tests         = new List <TestData>();

                foreach (var item in testsKeyValue)
                {
                    tests.Add(new TestData(item.Value, item.Key));
                }

                //get the tests
                //IEnumerable<string> tests = GetParamsWithPrefix("Test");

                IEnumerable <string>        jenkinsEnvVariablesWithCommas = GetParamsWithPrefix("JenkinsEnv");
                Dictionary <string, string> jenkinsEnvVariables           = new Dictionary <string, string>();
                foreach (string var in jenkinsEnvVariablesWithCommas)
                {
                    string[] nameVal = var.Split(",;".ToCharArray());
                    jenkinsEnvVariables.Add(nameVal[0], nameVal[1]);
                }
                //parse the timeout into a TimeSpan
                TimeSpan timeout = TimeSpan.MaxValue;
                if (_ciParams.ContainsKey("fsTimeout"))
                {
                    string strTimoutInSeconds = _ciParams["fsTimeout"];
                    if (strTimoutInSeconds.Trim() != "-1")
                    {
                        int intTimoutInSeconds = 0;
                        int.TryParse(strTimoutInSeconds, out intTimoutInSeconds);
                        timeout = TimeSpan.FromSeconds(intTimoutInSeconds);
                    }
                }
                ConsoleWriter.WriteLine("Launcher timeout is " + timeout.ToString(@"dd\:\:hh\:mm\:ss"));

                //LR specific values:
                //default values are set by JAVA code, in com.hpe.application.automation.tools.model.RunFromFileSystemModel.java

                int pollingInterval = 30;
                if (_ciParams.ContainsKey("controllerPollingInterval"))
                {
                    pollingInterval = int.Parse(_ciParams["controllerPollingInterval"]);
                }
                ConsoleWriter.WriteLine("Controller Polling Interval: " + pollingInterval + " seconds");

                TimeSpan perScenarioTimeOutMinutes = TimeSpan.MaxValue;
                if (_ciParams.ContainsKey("PerScenarioTimeOut"))
                {
                    string strTimoutInMinutes = _ciParams["PerScenarioTimeOut"];
                    //ConsoleWriter.WriteLine("reading PerScenarioTimeout: "+ strTimoutInMinutes);
                    if (strTimoutInMinutes.Trim() != "-1")
                    {
                        int intTimoutInMinutes = 0;
                        if (int.TryParse(strTimoutInMinutes, out intTimoutInMinutes))
                        {
                            perScenarioTimeOutMinutes = TimeSpan.FromMinutes(intTimoutInMinutes);
                        }
                        //ConsoleWriter.WriteLine("PerScenarioTimeout: "+perScenarioTimeOutMinutes+" minutes");
                    }
                }
                ConsoleWriter.WriteLine("PerScenarioTimeout: " + perScenarioTimeOutMinutes.ToString(@"dd\:\:hh\:mm\:ss") + " minutes");

                char[]        delim = { '\n' };
                List <string> ignoreErrorStrings = new List <string>();
                if (_ciParams.ContainsKey("ignoreErrorStrings"))
                {
                    if (_ciParams.ContainsKey("ignoreErrorStrings"))
                    {
                        ignoreErrorStrings.AddRange(Array.ConvertAll(_ciParams["ignoreErrorStrings"].Split(delim, StringSplitOptions.RemoveEmptyEntries), ignoreError => ignoreError.Trim()));
                    }
                }

                if (tests == null || tests.Count() == 0)
                {
                    WriteToConsole(Resources.LauncherNoTestsFound);
                }

                List <TestData> validTests = Helper.ValidateFiles(tests);

                if (tests != null && tests.Count() > 0 && validTests.Count == 0)
                {
                    ConsoleWriter.WriteLine(Resources.LauncherNoValidTests);
                    return(null);
                }

                //If a file path was provided and it doesn't exist stop the analysis launcher
                if (!analysisTemplate.Equals("") && !Helper.FileExists(analysisTemplate))
                {
                    return(null);
                }

                //--MC connection info
                McConnectionInfo mcConnectionInfo = new McConnectionInfo();
                if (_ciParams.ContainsKey("MobileHostAddress"))
                {
                    string mcServerUrl = _ciParams["MobileHostAddress"];

                    if (!string.IsNullOrEmpty(mcServerUrl))
                    {
                        //url is something like http://xxx.xxx.xxx.xxx:8080
                        string[] strArray = mcServerUrl.Split(new Char[] { ':' });
                        if (strArray.Length == 3)
                        {
                            mcConnectionInfo.MobileHostAddress = strArray[1].Replace("/", "");
                            mcConnectionInfo.MobileHostPort    = strArray[2];
                        }

                        //mc username
                        if (_ciParams.ContainsKey("MobileUserName"))
                        {
                            string mcUsername = _ciParams["MobileUserName"];
                            if (!string.IsNullOrEmpty(mcUsername))
                            {
                                mcConnectionInfo.MobileUserName = mcUsername;
                            }
                        }

                        //mc password
                        if (_ciParams.ContainsKey("MobilePassword"))
                        {
                            string mcPassword = _ciParams["MobilePassword"];
                            if (!string.IsNullOrEmpty(mcPassword))
                            {
                                mcConnectionInfo.MobilePassword = Decrypt(mcPassword, secretkey);
                            }
                        }

                        //mc tenantId
                        if (_ciParams.ContainsKey("MobileTenantId"))
                        {
                            string mcTenantId = _ciParams["MobileTenantId"];
                            if (!string.IsNullOrEmpty(mcTenantId))
                            {
                                mcConnectionInfo.MobileTenantId = mcTenantId;
                            }
                        }


                        //ssl
                        if (_ciParams.ContainsKey("MobileUseSSL"))
                        {
                            string mcUseSSL = _ciParams["MobileUseSSL"];
                            if (!string.IsNullOrEmpty(mcUseSSL))
                            {
                                mcConnectionInfo.MobileUseSSL = int.Parse(mcUseSSL);
                            }
                        }

                        //Proxy enabled flag
                        if (_ciParams.ContainsKey("MobileUseProxy"))
                        {
                            string useProxy = _ciParams["MobileUseProxy"];
                            if (!string.IsNullOrEmpty(useProxy))
                            {
                                mcConnectionInfo.MobileUseProxy = int.Parse(useProxy);
                            }
                        }


                        //Proxy type
                        if (_ciParams.ContainsKey("MobileProxyType"))
                        {
                            string proxyType = _ciParams["MobileProxyType"];
                            if (!string.IsNullOrEmpty(proxyType))
                            {
                                mcConnectionInfo.MobileProxyType = int.Parse(proxyType);
                            }
                        }


                        //proxy address
                        if (_ciParams.ContainsKey("MobileProxySetting_Address"))
                        {
                            string proxyAddress = _ciParams["MobileProxySetting_Address"];
                            if (!string.IsNullOrEmpty(proxyAddress))
                            {
                                // data is something like "16.105.9.23:8080"
                                string[] strArray4ProxyAddr = proxyAddress.Split(new Char[] { ':' });

                                if (strArray4ProxyAddr.Length == 2)
                                {
                                    mcConnectionInfo.MobileProxySetting_Address = strArray4ProxyAddr[0];
                                    mcConnectionInfo.MobileProxySetting_Port    = int.Parse(strArray4ProxyAddr[1]);
                                }
                            }
                        }

                        //Proxy authentication
                        if (_ciParams.ContainsKey("MobileProxySetting_Authentication"))
                        {
                            string proxyAuthentication = _ciParams["MobileProxySetting_Authentication"];
                            if (!string.IsNullOrEmpty(proxyAuthentication))
                            {
                                mcConnectionInfo.MobileProxySetting_Authentication = int.Parse(proxyAuthentication);
                            }
                        }

                        //Proxy username
                        if (_ciParams.ContainsKey("MobileProxySetting_UserName"))
                        {
                            string proxyUsername = _ciParams["MobileProxySetting_UserName"];
                            if (!string.IsNullOrEmpty(proxyUsername))
                            {
                                mcConnectionInfo.MobileProxySetting_UserName = proxyUsername;
                            }
                        }

                        //Proxy password
                        if (_ciParams.ContainsKey("MobileProxySetting_Password"))
                        {
                            string proxyPassword = _ciParams["MobileProxySetting_Password"];
                            if (!string.IsNullOrEmpty(proxyPassword))
                            {
                                mcConnectionInfo.MobileProxySetting_Password = Decrypt(proxyPassword, secretkey);
                            }
                        }
                    }
                }

                // other mobile info
                string mobileinfo = "";
                if (_ciParams.ContainsKey("mobileinfo"))
                {
                    mobileinfo = _ciParams["mobileinfo"];
                }

                Dictionary <string, List <String> > parallelRunnerEnvironments = new Dictionary <string, List <string> >();

                // retrieve the parallel runner environment for each test
                if (_ciParams.ContainsKey("parallelRunnerMode"))
                {
                    foreach (var test in validTests)
                    {
                        string        envKey           = "Parallel" + test.Id + "Env";
                        List <string> testEnvironments = GetParamsWithPrefix(envKey);

                        // add the environments for all the valid tests
                        parallelRunnerEnvironments.Add(test.Id, testEnvironments);
                    }
                }

                if (_ciParams.ContainsKey("fsUftRunMode"))
                {
                    string uftRunMode = "Fast";
                    uftRunMode = _ciParams["fsUftRunMode"];
                    runner     = new FileSystemTestsRunner(validTests, timeout, uftRunMode, pollingInterval, perScenarioTimeOutMinutes, ignoreErrorStrings, jenkinsEnvVariables, mcConnectionInfo, mobileinfo, parallelRunnerEnvironments, displayController, analysisTemplate);
                }
                else
                {
                    runner = new FileSystemTestsRunner(validTests, timeout, pollingInterval, perScenarioTimeOutMinutes, ignoreErrorStrings, jenkinsEnvVariables, mcConnectionInfo, mobileinfo, parallelRunnerEnvironments, displayController, analysisTemplate);
                }

                break;

            default:
                runner = null;
                break;
            }
            return(runner);
        }
        /// <summary>
        /// creates instance of the runner given a source.
        /// </summary>
        /// <param name="sources"></param>
        /// <param name="timeout"></param>
        /// <param name="backgroundWorker"></param>
        /// <param name="useUFTLicense"></param>
        public FileSystemTestsRunner(List<string> sources,
            TimeSpan timeout,
            int ControllerPollingInterval,
            TimeSpan perScenarioTimeOutMinutes,
            List<string> ignoreErrorStrings,
            Dictionary<string, string> jenkinsEnvVariables,
            McConnectionInfo mcConnection,
            string mobileInfo,
            bool useUFTLicense = false
            )
        {
            _jenkinsEnvVariables = jenkinsEnvVariables;
            //search if we have any testing tools installed
            if (!Helper.IsTestingToolsInstalled(TestStorageType.FileSystem))
            {
                ConsoleWriter.WriteErrLine(string.Format(Resources.FileSystemTestsRunner_No_HP_testing_tool_is_installed_on, System.Environment.MachineName));
                Environment.Exit((int)Launcher.ExitCodeEnum.Failed);
            }

            _timeout = timeout;
            ConsoleWriter.WriteLine("FileSystemTestRunner timeout is " + _timeout );
            _stopwatch = Stopwatch.StartNew();

            _pollingInterval = ControllerPollingInterval;
            _perScenarioTimeOutMinutes = perScenarioTimeOutMinutes;
            _ignoreErrorStrings = ignoreErrorStrings;

            _useUFTLicense = useUFTLicense;
            _tests = new List<TestInfo>();

            _mcConnection = mcConnection;
            _mobileInfoForAllGuiTests = mobileInfo;

            ConsoleWriter.WriteLine("Mc connection info is - " + _mcConnection.ToString());

            //go over all sources, and create a list of all tests
            foreach (string source in sources)
            {
                List<TestInfo> testGroup = new List<TestInfo>();
                try
                {
                    //--handle directories which contain test subdirectories (recursively)
                    if (Helper.IsDirectory(source))
                    {

                        var testsLocations = Helper.GetTestsLocations(source);
                        foreach (var loc in testsLocations)
                        {
                            var test = new TestInfo(loc, loc, source);
                            testGroup.Add(test);
                        }
                    }
                    //--handle mtb files (which contain links to tests)
                    else
                    //file might be LoadRunner scenario or
                    //mtb file (which contain links to tests)
                    //other files are dropped
                    {
                        testGroup = new List<TestInfo>();
                        FileInfo fi = new FileInfo(source);
                        if (fi.Extension == Helper.LoadRunnerFileExtention)
                            testGroup.Add(new TestInfo(source, source, source));
                        else if (fi.Extension == ".mtb")
                        //if (source.TrimEnd().EndsWith(".mtb", StringComparison.CurrentCultureIgnoreCase))
                        {
                            MtbManager manager = new MtbManager();
                            var paths = manager.Parse(source);
                            foreach (var p in paths)
                            {
                                testGroup.Add(new TestInfo(p, p, source));
                            }
                        }
                        else if (fi.Extension == ".mtbx")
                        //if (source.TrimEnd().EndsWith(".mtb", StringComparison.CurrentCultureIgnoreCase))
                        {
                            testGroup = MtbxManager.Parse(source, _jenkinsEnvVariables, source);
                        }
                    }
                }
                catch (Exception)
                {
                    testGroup = new List<TestInfo>();
                }

                //--handle single test dir, add it with no group
                if (testGroup.Count == 1)
                {
                    testGroup[0].TestGroup = "<None>";
                }

                _tests.AddRange(testGroup);
            }

            if (_tests == null || _tests.Count == 0)
            {
                ConsoleWriter.WriteLine(Resources.FsRunnerNoValidTests);
                Environment.Exit((int)Launcher.ExitCodeEnum.Failed);
            }

            ConsoleWriter.WriteLine(string.Format(Resources.FsRunnerTestsFound, _tests.Count));
            _tests.ForEach(t => ConsoleWriter.WriteLine("" + t.TestName));
            ConsoleWriter.WriteLine(Resources.GeneralDoubleSeperator);
        }
        /// <summary>
        /// creates the correct runner according to the given type
        /// </summary>
        /// <param name="runType"></param>
        /// <param name="ciParams"></param>
        /// <param name="initialTestRun"></param>
        private IAssetRunner CreateRunner(TestStorageType runType, JavaProperties ciParams, bool initialTestRun)
        {
            IAssetRunner runner = null;

            switch (runType)
            {
            case TestStorageType.Alm:
                //check that all required parameters exist
                foreach (string param1 in requiredParamsForQcRun)
                {
                    if (!_ciParams.ContainsKey(param1))
                    {
                        ConsoleWriter.WriteLine(string.Format(Resources.LauncherParamRequired, param1));
                        return(null);
                    }
                }

                //parse params that need parsing
                double dblQcTimeout = int.MaxValue;
                if (!double.TryParse(_ciParams["almTimeout"], out dblQcTimeout))
                {
                    ConsoleWriter.WriteLine(Resources.LauncherTimeoutNotNumeric);
                    dblQcTimeout = int.MaxValue;
                }

                ConsoleWriter.WriteLine(string.Format(Resources.LuancherDisplayTimout, dblQcTimeout));

                QcRunMode enmQcRunMode = QcRunMode.RUN_LOCAL;
                if (!Enum.TryParse <QcRunMode>(_ciParams["almRunMode"], true, out enmQcRunMode))
                {
                    ConsoleWriter.WriteLine(Resources.LauncherIncorrectRunmode);
                    enmQcRunMode = QcRunMode.RUN_LOCAL;
                }
                ConsoleWriter.WriteLine(string.Format(Resources.LauncherDisplayRunmode, enmQcRunMode.ToString()));

                //go over test sets in the parameters, and collect them
                List <string> sets = GetParamsWithPrefix("TestSet");

                if (sets.Count == 0)
                {
                    ConsoleWriter.WriteLine(Resources.LauncherNoTests);
                    return(null);
                }

                //check if filterTests flag is selected; if yes apply filters on the list

                bool   isFilterSelected;
                string filter = _ciParams.ContainsKey("FilterTests") ? _ciParams["FilterTests"] : "";

                isFilterSelected = !string.IsNullOrEmpty(filter) && Convert.ToBoolean(filter.ToLower());

                string filterByName = _ciParams.ContainsKey("FilterByName") ? _ciParams["FilterByName"] : "";

                string statuses = _ciParams.ContainsKey("FilterByStatus") ? _ciParams["FilterByStatus"] : "";

                List <string> filterByStatuses = new List <string>();

                if (statuses != "")
                {
                    if (statuses.Contains(","))
                    {
                        filterByStatuses = statuses.Split(',').ToList();
                    }
                    else
                    {
                        filterByStatuses.Add(statuses);
                    }
                }

                bool isSSOEnabled = _ciParams.ContainsKey("SSOEnabled") && Convert.ToBoolean(_ciParams["SSOEnabled"]);

                //create an Alm runner
                runner = new AlmTestSetsRunner(_ciParams["almServerUrl"],
                                               _ciParams["almUserName"],
                                               Decrypt(_ciParams["almPassword"], _secretKey),
                                               _ciParams["almDomain"],
                                               _ciParams["almProject"],
                                               dblQcTimeout,
                                               enmQcRunMode,
                                               _ciParams["almRunHost"],
                                               sets,
                                               isFilterSelected,
                                               filterByName,
                                               filterByStatuses,
                                               initialTestRun,
                                               TestStorageType.Alm,
                                               isSSOEnabled,
                                               _ciParams["almClientID"], Decrypt(_ciParams["almApiKey"], _secretKey));
                break;

            case TestStorageType.FileSystem:
                bool displayController = false;
                if (_ciParams.ContainsKey("displayController"))
                {
                    if (_ciParams["displayController"] == "1")
                    {
                        displayController = true;
                    }
                }
                string analysisTemplate = (_ciParams.ContainsKey("analysisTemplate") ? _ciParams["analysisTemplate"] : "");

                List <TestData> validBuildTests = GetValidTests("Test", Resources.LauncherNoTestsFound, Resources.LauncherNoValidTests);

                //add build tests and cleanup tests in correct order
                List <TestData> validTests = new List <TestData>();

                if (!_rerunFailedTests)
                {
                    ConsoleWriter.WriteLine("Run build tests");

                    //run only the build tests
                    foreach (var item in validBuildTests)
                    {
                        validTests.Add(item);
                    }
                }
                else
                {     //add also cleanup tests
                    string fsTestType = (_ciParams.ContainsKey("testType") ? _ciParams["testType"] : "");

                    List <TestData> validFailedTests  = GetValidTests("FailedTest", Resources.LauncherNoFailedTestsFound, Resources.LauncherNoValidFailedTests);
                    List <TestData> validCleanupTests = new List <TestData>();
                    if (GetValidTests("CleanupTest", Resources.LauncherNoCleanupTestsFound, Resources.LauncherNoValidCleanupTests).Count > 0)
                    {
                        validCleanupTests = GetValidTests("CleanupTest", Resources.LauncherNoCleanupTestsFound, Resources.LauncherNoValidCleanupTests);
                    }
                    List <string> reruns         = GetParamsWithPrefix("Reruns");
                    List <int>    numberOfReruns = new List <int>();
                    foreach (var item in reruns)
                    {
                        numberOfReruns.Add(int.Parse(item));
                    }

                    bool noRerunsSet = CheckListOfRerunValues(numberOfReruns);

                    if (noRerunsSet)
                    {
                        ConsoleWriter.WriteLine("In order to rerun the tests the number of reruns should be greater than zero.");
                    }
                    else
                    {
                        for (int i = 0; i < numberOfReruns.Count; i++)
                        {
                            var currentRerun = numberOfReruns.ElementAt(i);

                            if (fsTestType.Equals("Of any of the build's tests"))
                            {
                                ConsoleWriter.WriteLine("Rerun the entire test set");
                                while (currentRerun > 0)
                                {
                                    if (validCleanupTests.Count > 0)
                                    {
                                        validTests.Add(validCleanupTests.ElementAt(i));
                                    }

                                    foreach (var item in validFailedTests)
                                    {
                                        validTests.Add(item);
                                    }

                                    currentRerun--;
                                }
                            }
                            else
                            {
                                while (currentRerun > 0)
                                {
                                    if (validCleanupTests.Count > 0)
                                    {
                                        validTests.Add(validCleanupTests.ElementAt(i));
                                    }

                                    validTests.Add(validFailedTests.ElementAt(i));

                                    currentRerun--;
                                }
                            }
                        }
                    }
                }

                //get the tests
                //IEnumerable<string> tests = GetParamsWithPrefix("Test");

                IEnumerable <string>        jenkinsEnvVariablesWithCommas = GetParamsWithPrefix("JenkinsEnv");
                Dictionary <string, string> jenkinsEnvVariables           = new Dictionary <string, string>();
                foreach (string var in jenkinsEnvVariablesWithCommas)
                {
                    string[] nameVal = var.Split(",;".ToCharArray());
                    jenkinsEnvVariables.Add(nameVal[0], nameVal[1]);
                }
                //parse the timeout into a TimeSpan
                TimeSpan timeout = TimeSpan.MaxValue;
                if (_ciParams.ContainsKey("fsTimeout"))
                {
                    string strTimeoutInSeconds = _ciParams["fsTimeout"];
                    if (strTimeoutInSeconds.Trim() != "-1")
                    {
                        int intTimeoutInSeconds = 0;
                        int.TryParse(strTimeoutInSeconds, out intTimeoutInSeconds);
                        timeout = TimeSpan.FromSeconds(intTimeoutInSeconds);
                    }
                }
                ConsoleWriter.WriteLine("Launcher timeout is " + timeout.ToString(@"dd\:\:hh\:mm\:ss"));

                //LR specific values:
                //default values are set by JAVA code, in com.hpe.application.automation.tools.model.RunFromFileSystemModel.java

                int pollingInterval = 30;
                if (_ciParams.ContainsKey("controllerPollingInterval"))
                {
                    pollingInterval = int.Parse(_ciParams["controllerPollingInterval"]);
                }
                ConsoleWriter.WriteLine("Controller Polling Interval: " + pollingInterval + " seconds");

                TimeSpan perScenarioTimeOutMinutes = TimeSpan.MaxValue;
                if (_ciParams.ContainsKey("PerScenarioTimeOut"))
                {
                    string strTimeoutInMinutes = _ciParams["PerScenarioTimeOut"];
                    //ConsoleWriter.WriteLine("reading PerScenarioTimeout: "+ strTimoutInMinutes);
                    if (strTimeoutInMinutes.Trim() != "-1")
                    {
                        int intTimoutInMinutes = 0;
                        if (int.TryParse(strTimeoutInMinutes, out intTimoutInMinutes))
                        {
                            perScenarioTimeOutMinutes = TimeSpan.FromMinutes(intTimoutInMinutes);
                        }
                        //ConsoleWriter.WriteLine("PerScenarioTimeout: "+perScenarioTimeOutMinutes+" minutes");
                    }
                }
                ConsoleWriter.WriteLine("PerScenarioTimeout: " + perScenarioTimeOutMinutes.ToString(@"dd\:\:hh\:mm\:ss") + " minutes");

                char[]        delimiter          = { '\n' };
                List <string> ignoreErrorStrings = new List <string>();
                if (_ciParams.ContainsKey("ignoreErrorStrings"))
                {
                    if (_ciParams.ContainsKey("ignoreErrorStrings"))
                    {
                        ignoreErrorStrings.AddRange(Array.ConvertAll(_ciParams["ignoreErrorStrings"].Split(delimiter, StringSplitOptions.RemoveEmptyEntries), ignoreError => ignoreError.Trim()));
                    }
                }

                //If a file path was provided and it doesn't exist stop the analysis launcher
                if (!analysisTemplate.Equals("") && !Helper.FileExists(analysisTemplate))
                {
                    return(null);
                }

                //--MC connection info
                McConnectionInfo mcConnectionInfo = new McConnectionInfo();
                if (_ciParams.ContainsKey("MobileHostAddress"))
                {
                    string mcServerUrl = _ciParams["MobileHostAddress"];

                    if (!string.IsNullOrEmpty(mcServerUrl))
                    {
                        //url is something like http://xxx.xxx.xxx.xxx:8080
                        string[] strArray = mcServerUrl.Split(new Char[] { ':' });
                        if (strArray.Length == 3)
                        {
                            mcConnectionInfo.MobileHostAddress = strArray[1].Replace("/", "");
                            mcConnectionInfo.MobileHostPort    = strArray[2];
                        }

                        //mc username
                        if (_ciParams.ContainsKey("MobileUserName"))
                        {
                            string mcUsername = _ciParams["MobileUserName"];
                            if (!string.IsNullOrEmpty(mcUsername))
                            {
                                mcConnectionInfo.MobileUserName = mcUsername;
                            }
                        }

                        //mc password
                        if (_ciParams.ContainsKey("MobilePassword"))
                        {
                            string mcPassword = _ciParams["MobilePassword"];
                            if (!string.IsNullOrEmpty(mcPassword))
                            {
                                mcConnectionInfo.MobilePassword = Decrypt(mcPassword, _secretKey);
                            }
                        }

                        //mc tenantId
                        if (_ciParams.ContainsKey("MobileTenantId"))
                        {
                            string mcTenantId = _ciParams["MobileTenantId"];
                            if (!string.IsNullOrEmpty(mcTenantId))
                            {
                                mcConnectionInfo.MobileTenantId = mcTenantId;
                            }
                        }


                        //ssl
                        if (_ciParams.ContainsKey("MobileUseSSL"))
                        {
                            string mcUseSSL = _ciParams["MobileUseSSL"];
                            if (!string.IsNullOrEmpty(mcUseSSL))
                            {
                                mcConnectionInfo.MobileUseSSL = int.Parse(mcUseSSL);
                            }
                        }

                        //Proxy enabled flag
                        if (_ciParams.ContainsKey("MobileUseProxy"))
                        {
                            string useProxy = _ciParams["MobileUseProxy"];
                            if (!string.IsNullOrEmpty(useProxy))
                            {
                                mcConnectionInfo.MobileUseProxy = int.Parse(useProxy);
                            }
                        }


                        //Proxy type
                        if (_ciParams.ContainsKey("MobileProxyType"))
                        {
                            string proxyType = _ciParams["MobileProxyType"];
                            if (!string.IsNullOrEmpty(proxyType))
                            {
                                mcConnectionInfo.MobileProxyType = int.Parse(proxyType);
                            }
                        }


                        //proxy address
                        if (_ciParams.ContainsKey("MobileProxySetting_Address"))
                        {
                            string proxyAddress = _ciParams["MobileProxySetting_Address"];
                            if (!string.IsNullOrEmpty(proxyAddress))
                            {
                                // data is something like "16.105.9.23:8080"
                                string[] strArrayForProxyAddress = proxyAddress.Split(new Char[] { ':' });

                                if (strArrayForProxyAddress.Length == 2)
                                {
                                    mcConnectionInfo.MobileProxySetting_Address = strArrayForProxyAddress[0];
                                    mcConnectionInfo.MobileProxySetting_Port    = int.Parse(strArrayForProxyAddress[1]);
                                }
                            }
                        }

                        //Proxy authentication
                        if (_ciParams.ContainsKey("MobileProxySetting_Authentication"))
                        {
                            string proxyAuthentication = _ciParams["MobileProxySetting_Authentication"];
                            if (!string.IsNullOrEmpty(proxyAuthentication))
                            {
                                mcConnectionInfo.MobileProxySetting_Authentication = int.Parse(proxyAuthentication);
                            }
                        }

                        //Proxy username
                        if (_ciParams.ContainsKey("MobileProxySetting_UserName"))
                        {
                            string proxyUsername = _ciParams["MobileProxySetting_UserName"];
                            if (!string.IsNullOrEmpty(proxyUsername))
                            {
                                mcConnectionInfo.MobileProxySetting_UserName = proxyUsername;
                            }
                        }

                        //Proxy password
                        if (_ciParams.ContainsKey("MobileProxySetting_Password"))
                        {
                            string proxyPassword = _ciParams["MobileProxySetting_Password"];
                            if (!string.IsNullOrEmpty(proxyPassword))
                            {
                                mcConnectionInfo.MobileProxySetting_Password = Decrypt(proxyPassword, _secretKey);
                            }
                        }
                    }
                }

                // other mobile info
                string mobileinfo = "";
                if (_ciParams.ContainsKey("mobileinfo"))
                {
                    mobileinfo = _ciParams["mobileinfo"];
                }

                Dictionary <string, List <String> > parallelRunnerEnvironments = new Dictionary <string, List <string> >();

                // retrieve the parallel runner environment for each test
                if (_ciParams.ContainsKey("parallelRunnerMode"))
                {
                    foreach (var test in validTests)
                    {
                        string        envKey           = "Parallel" + test.Id + "Env";
                        List <string> testEnvironments = GetParamsWithPrefix(envKey);

                        // add the environments for all the valid tests
                        parallelRunnerEnvironments.Add(test.Id, testEnvironments);
                    }
                }

                // users can provide a custom report path
                string reportPath = null;
                if (_ciParams.ContainsKey("fsReportPath"))
                {
                    reportPath = _ciParams["fsReportPath"];
                }

                SummaryDataLogger     summaryDataLogger = GetSummaryDataLogger();
                List <ScriptRTSModel> scriptRTSSet      = GetScriptRtsSet();
                if (_ciParams.ContainsKey("fsUftRunMode"))
                {
                    string uftRunMode = "Fast";
                    uftRunMode = _ciParams["fsUftRunMode"];
                    runner     = new FileSystemTestsRunner(validTests, timeout, uftRunMode, pollingInterval, perScenarioTimeOutMinutes, ignoreErrorStrings, jenkinsEnvVariables, mcConnectionInfo, mobileinfo, parallelRunnerEnvironments, displayController, analysisTemplate, summaryDataLogger, scriptRTSSet, reportPath);
                }
                else
                {
                    runner = new FileSystemTestsRunner(validTests, timeout, pollingInterval, perScenarioTimeOutMinutes, ignoreErrorStrings, jenkinsEnvVariables, mcConnectionInfo, mobileinfo, parallelRunnerEnvironments, displayController, analysisTemplate, summaryDataLogger, scriptRTSSet, reportPath);
                }

                break;

            default:
                runner = null;
                break;
            }
            return(runner);
        }