示例#1
0
        private static void Run(Action f)
        {
            try
            {
                TestCases.SuiteSetup();

                string testCaseName = f.Method.ToString().Replace("Void ", "").Replace("()", "");

                if (testCaseName.StartsWith("Test_"))
                {
                    testCasesCount++;
                }

                foreach (string regexFilter in TestCases.runFilters)
                {
                    Match match = Regex.Match(testCaseName, regexFilter, RegexOptions.IgnoreCase);
                    if (TestCases.matchExactName == false || (match.Success && (TestCases.matchExactName && testCaseName == regexFilter)))
                    {
                        Console.WriteLine("Executing: [" + testCaseName + "]" + "...");
                        executed++;

                        try
                        {
                            TestCases.TestSetup();
                            f();
                            TestCases.TestCleanup();

                            passed++;
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Error: " + ex.Message);
                            Console.WriteLine("Details: " + ex.StackTrace);
                        }

                        break; //exit foreach, as test case name might match multiple filters
                    }
                    else
                    {
                        //Console.WriteLine("Skipped: [" + testCaseName + "]");
                    }
                }
            }
            finally
            {
                TestCases.SuiteCleanup();
            }
        }