コード例 #1
0
        public override TestResult Execute()
        {
            TestItems children = Children;

            if (children != null && children.Count > 0)
            {
                // this is not a leaf node, just invoke all the children's execute
                foreach (object child in children)
                {
                    TestCase tc = child as TestCase;
                    if (tc != null)
                    {
                        if (TestInput.IsTestCaseSelected(tc.Name))
                        {
                            Console.WriteLine("TestCase:{0} - {1}", tc.Attribute.Name, tc.Attribute.Desc);
                            tc.Init();
                            tc.Execute();
                        }
                    }
                }
            }
            Console.WriteLine("Pass:{0}, Fail:{1}, Skip:{2}", PassCount, FailCount, SkipCount);
            return(TestResult.Passed);
        }
コード例 #2
0
ファイル: testcase.cs プロジェクト: rsumner31/corefx2
        public override TestResult Execute()
        {
            base.Execute();
            TestModule module = GetModule();

            if (module == null)
            {
                throw new Exception("No parent module");
            }
            TestItems children = Children;

            if (children != null && children.Count > 0)
            {
                // this is not a leaf node, just invoke all the children's execute
                foreach (object child in children)
                {
                    if (child is TestCase)
                    {
                        TestCase t = child as TestCase;
                        t.Init();
                        t.Execute();
                        continue;
                    }
                    TestVariation var = child as TestVariation;
                    if (var != null)
                    {
                        const string indent = "\t";
                        try
                        {
                            CurVariation = var;
                            TestResult ret = var.Execute();
                            if (TestResult.Passed == ret)
                            {
                                module.PassCount++;
                            }
                            else if (TestResult.Failed == ret)
                            {
                                System.Console.WriteLine(indent + var.Desc);
                                System.Console.WriteLine(indent + " FAILED");
                                module.FailCount++;
                            }
                            else
                            {
                                System.Console.WriteLine(indent + var.Desc);
                                System.Console.WriteLine(indent + " SKIPPED");
                                module.SkipCount++;
                            }
                        }
                        catch (TestSkippedException tse)
                        {
                            if (!string.IsNullOrWhiteSpace(var.Desc))
                            {
                                System.Console.WriteLine(indent + var.Desc);
                            }
                            if (!string.IsNullOrWhiteSpace(tse.Message))
                            {
                                System.Console.WriteLine(indent + " SKIPPED" + ", Msg:" + tse.Message);
                            }
                            module.SkipCount++;
                        }
                        catch (Exception e)
                        {
                            System.Console.WriteLine(indent + var.Desc);
                            System.Console.WriteLine(e);
                            System.Console.WriteLine(indent + " FAILED");
                            module.FailCount++;
                        }
                    }
                }
            }
            return(TestResult.Passed);
        }