HpToolsLauncher.Helper.GetTestType C# (CSharp) Method

GetTestType() public static method

public static GetTestType ( string path ) : TestType
path string
return TestType
        public static TestType GetTestType(string path)
        {
            if ((File.GetAttributes(path) & FileAttributes.Directory) == FileAttributes.Directory)
            {
            //ST and QTP uses folder as test locations
                var stFiles = Directory.GetFiles(path,
                    @"*.st?",
                    SearchOption.TopDirectoryOnly);

                return (stFiles.Count() > 0) ? TestType.ST : TestType.QTP;
            }
            else //not directory
            {
            //loadrunner is a path to file...
                return TestType.LoadRunner;
            }
        }

Usage Example

Example #1
0
        /// <summary>
        /// creates a correct type of runner and runs a single test.
        /// </summary>
        /// <param name="testPath"></param>
        /// <param name="errorReason"></param>
        /// <returns></returns>
        private TestRunResults RunHPToolsTest(TestInfo testinf, ref string errorReason)
        {
            var testPath = testinf.TestPath;
            var type     = Helper.GetTestType(testPath);
            IFileSysTestRunner runner = null;

            switch (type)
            {
            case TestType.ST:
                runner = new ApiTestRunner(this, _timeout - _stopwatch.Elapsed);
                break;

            case TestType.QTP:
                runner = new GuiTestRunner(this, _useUFTLicense, _timeout - _stopwatch.Elapsed, _mcConnection, _mobileInfoForAllGuiTests);
                break;

            case TestType.LoadRunner:
                AppDomain.CurrentDomain.AssemblyResolve += Helper.HPToolsAssemblyResolver;
                runner = new PerformanceTestRunner(this, _timeout, _pollingInterval, _perScenarioTimeOutMinutes, _ignoreErrorStrings);
                break;
            }


            if (runner != null)
            {
                if (!_colRunnersForCleanup.ContainsKey(type))
                {
                    _colRunnersForCleanup.Add(type, runner);
                }

                Stopwatch s = Stopwatch.StartNew();

                TestRunResults results = null;

                results = runner.RunTest(testinf, ref errorReason, RunCancelled);

                results.Runtime = s.Elapsed;
                if (type == TestType.LoadRunner)
                {
                    AppDomain.CurrentDomain.AssemblyResolve -= Helper.HPToolsAssemblyResolver;
                }

                return(results);
            }

            //check for abortion
            if (System.IO.File.Exists(_abortFilename))
            {
                ConsoleWriter.WriteLine(Resources.GeneralStopAborted);

                //stop working
                Environment.Exit((int)Launcher.ExitCodeEnum.Aborted);
            }

            return(new TestRunResults {
                ErrorDesc = "Unknown TestType", TestState = TestState.Error
            });
        }
All Usage Examples Of HpToolsLauncher.Helper::GetTestType